3 ms·
According to POSIX, variables that contain lower-case letters are for application use. If Debian (or whoever) introduces such variable names, they are being non
by kazinator 7y ago
According to POSIX, variables that contain lower-case letters are for application use. If Debian (or whoever) introduces such variable names, they are being nonconforming.
For instance, my programs might be in /home/kaz/bin. Suppose I create a one-letter variable:
k=/home/kaz/bin
Then /home/kaz/bin/foo can be run as
$k/foo
Bash will complete on this. Firstly, $k[Tab] will add the missing slash to make $k/. Then if Tab is hit twice, the completions under /home/kaz/bin are shown.
Since k contains an absolute path, it does not rely on PATH searching.
The programs under $k/ can refer to each other using the $k/ notation, without relying on PATH.
The comma notation relies on PATH. When the ,foo script wants to invoke the ,bar script and just calls it ,bar args ... that relies on PATH containing the directory in which ,bar lives.
For interactive use, I'd use PATH anyway: put /home/kaz/bin at the end. Then if the system shadows one of my programs prog, I can just use ~/utils/prog or $k/prog to detour around the clashing system program. My programs themselves don't rely on PATH for calling each other, so they are immune to the shadowing, and since I added the new PATH element at the end, I haven't perpetrated any shadowing that would break system programs.
- saagarjha 7y agoUnfortunately, some bash completion scripts will expand $k to \$k…
- kazinator 7y agoThat indicates they are broken. Completion scripts must not break basic completion features like completing shell variables.
- aliveupstairs 7y agoIf you are using absolute paths, I found this easier to get used to: hash -d b=/home/me/bin Then you call foo as: ~b/foo I have an array of these defined to my most used directories.
- mineo 7y agoI believe hash -d and supsequent expansion of those paths only works in ZSH, which calls this "static named directories" (http://zsh.sourceforge.net/Doc/Release/Expansion.html#Static-named-directories http://zsh.sourceforge.net/Doc/Release/Expansion.html#Static...).