4 ms·
One of my pet peeves is CLI newbies who always have the need to cd into some directory before running a command. I learnt pretty early on that this was stupid.
by bradwood 4y ago
One of my pet peeves is CLI newbies who always have the need to cd into some directory before running a command. I learnt pretty early on that this was stupid.
Just run your command from the repo root or $HOME.
- taskforcegemini 4y agoimho that is not a bad habit to have, what's the harm? you don't always know how the script/application behaves. sometimes they do things in relation to where you are standing. if you mean the newbies cd into a location in $PATH though, i.e.: cd /bin, cd /usr/bin etcetera I agree, that doesn't make sense usually
- eikenberry 4y agoTo be fair most of those newbies are probably writing scripts that use relative directories so they require them being run in the same directory. Newbies tend to reinforce bad habits like that which makes it harder to break out of those ruts.
- bradwood 4y ago(cd ./some/path; ./script.sh)
- eikenberry 4y agoIMO it's easier just to write your scripts so they don't rely on the directory context for running correctly. Usually it's just a matter of taking your relative path using script and sticking something like this at the top and you're good. cd "$(dirname $0)"