Bash scripting issue with "source" or . (dot) operator (Cygwin & Ubuntu)
Hi All,
This one is driving me crazy. My .bashrc is set as: if [ -d ~/.bashrc.d ]; then for file in $(/bin/ls ~/.bashrc.d/); do . '~/.bashrc.d/'$file done fi So in theory any files located in the ~/.bashrc.d/ directory will automatically get loaded. great! The problem is that when running the script, the file (that it has already found) that it tries to load gives an error like: bash: ~/.bashrc.d/aliases: No such file or directory I've debugged and debugged but the best I've come up with is the line doing the source (the . ) is: . ~/.bashrc.d/aliases (the file does exist btw) if I run the same command from the shell it works fine and all my aliases load correctly. Can anyone help me please? I'm getting this in Cygwin and Ubuntu. Thanks, Brian |
Hi All,
I figured it out: . '~/.bashrc.d/'$file should have been: . ~/.bashrc.d/$file Then it all works correctly. I hope this helps someone, someday. Brian |
You are doing two things wrong here:
1. Trying to do anything besides display the output of "ls" 2. Using single-quotes instead of double-quotes Code:
shopt -s nullglob |
Thanks very much!
|
All times are GMT -5. The time now is 01:52 PM. |