New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$PATH contains spaces instead of colons #1744
Comments
$PATH does not contain spaces. It is a list. When it is exported, it is colon delimited. |
You mean, when it is exported in bash? |
When fish exports PATH, it is colon-delimited. Try echo $PATH looks at the value of the variable in fish (where it's a list), not the value of the variable in the environment. |
Thats what I ended up using in here franciscolourenco/SublimeFixMacPath@b9369ed I think I understand what you are saying.. |
So lists in fish are like arrays in other languages (e.g. Python or JavaScript). They're not delimited by anything; they're an indexed sequence of values under a single variable name. When you pass a list to a command, each value in the list becomes a separate argument. echo makes it appear space delimited, because echo just space-separates its argument. But you can do other stuff with lists too:
Certainly in that case we want each file to be a separate argument, not a single colon-separated argument. PATH is interpreted as a list, which brings lots of advantages. For example, to delete the last element in PATH, it's just I took a look at the commit. It's gratifying to see improved fish support in Sublime 👍 Using Hope that clears things up! |
Great explanation, thank you a lot for answering so promptly! |
You're welcome, and thanks for taking the time to write this up. |
Actually, no. But it's not easy either, as you need to modify a special variable. (
IFS=:
for path in $PATH
do
echo "Found path: $path."
done
) |
Is it possible for fish to read bash PATH exports?
export PATH="/new/path:$PATH" source newpath.sh Is there an adjustment I could make so that this will work in both |
@solderjs: In fish >= 3.0, that'll work, as fish splits $PATH on colons since then, and joins it with colons in quotes. HOWEVER: In general, it can't be guaranteed that a script will work in bash and fish, and the common subset is quite small (no blocks at all - no Also questions like this are better asked at gitter.im/fish-shell/fish-shell instead of in closed issues. |
Ah, I'm on fish 2.5.0
However, Google can't find things on gitter (or if it can, it doesn't rank them), and since my search lead me here, it will likely lead someone else (such as future me) here again. |
See https://fishshell.com for our variety of PPAs and repositories, or build it yourself. |
Thanks. I got it working. This is what I was creating: Pathman
|
bash -> /usr/local/bin:/usr/local/sbin:/usr/bin
fish -> /usr/local/bin /usr/local/sbin /usr/bin
Isn't this bad for programs which might need to parse $PATH and are expecting directories to be separated by colons?
The text was updated successfully, but these errors were encountered: