Skip to content

Instantly share code, notes, and snippets.

@rianoc
Created April 18, 2021 08:17
Show Gist options
  • Save rianoc/34f2bc024543c953ae769c7dcee2bfdc to your computer and use it in GitHub Desktop.
Save rianoc/34f2bc024543c953ae769c7dcee2bfdc to your computer and use it in GitHub Desktop.
Kdb+ PATH and LD_LIBRARY_PATH manipulation
addToBeginning:{x setenv y,":",":" sv {x where not x~\:""}":" vs getenv x}
addToEnd:{x setenv (":" sv {x where not x~\:""}":" vs getenv x),":",y}
remove:{x setenv ":" sv {x where not any x like/:("";y)}[;y]":" vs getenv x}
pushToEnd:{x setenv ":" sv {x iasc x like y}[;y] {x where not x~\:""}":" vs getenv x}
bringForward:{x setenv ":" sv {x idesc x like y}[;y] {x where not x~\:""}":" vs getenv x}

Add where needed:

addToBeginning[`PATH;"/home/user/bin/"]
addToEnd[`PATH;"/home/user/bin/"]

Remove unwanted:

remove[`PATH;"*anaconda*"]

Issues being caused by order:

pushToEnd[`LD_LIBRARY_PATH;"*anaconda*"]
bringForward[`LD_LIBRARY_PATH;"*anaconda*"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment