by koolba · 5y ago · 0 comments
Eh? This breaks all relative path arguments:
/path/to/foo.sh bar.txt
If you need to reference relative path data internally then that should be hidden from the caller by that same logic, but used only internally.I do something similar with scripts that are within projects. There are scripts named the same but vary due to each project being different so I can't use $PATH (unless I export it every single time I change projects and open a terminal for it)
Commands are relative and sometimes these can be executed by other things. Other scripts, cron, etc. depending on the environment and the use. So, first step, cd into the correct directory and then run everything relative to it.
It doesn’t make sense for generalized scripts that automate routine tasks. But for some maintenance, build, test, or deploy scripts that only ever perform a specialized job from a single location, it could be handy. I appreciate that Maciej provided it. Always easier to remove it than have to go find it yourself in the odd script you might need it.
Apparently this is for some category of utility that is a "bash script", not "a unix style command implemented in bash".
Make small utilities, call them for each other, or chain them with pipes. 99% of the time that will make more sense.