From cd64c716707cc2ab7029d1fc5b2272456a0f0b2a Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 26 Jul 2014 13:06:19 -0700 Subject: [PATCH] Created SC2147 (markdown) --- SC2147.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SC2147.md diff --git a/SC2147.md b/SC2147.md new file mode 100644 index 0000000..48e1881 --- /dev/null +++ b/SC2147.md @@ -0,0 +1,23 @@ +## Literal tilde in PATH works poorly across programs. + +### Problematic code: + + PATH="$PATH:~/bin" + +### Correct code: + + PATH="$PATH:$HOME/bin" + +### Rationale: + +Having literal `~` in PATH is a bad idea. Bash handles it, but nothing else does. + +This means that even if you're always using Bash, you should avoid it because any invoked program that relies on PATH will effectively ignore those entries. + +For example, `make` may say `foo: Command not found` even though `foo` works fine from the shell and Make and Bash both use the same PATH. You'll get similar messages from any non-bash scripts invoked, and `whereis` will come up empty. + +Use `$HOME` or full path instead. + +### Contraindications + +If your directory name actually contains a literal tilde, you can ignore this message. \ No newline at end of file