Skip to main content
11 events
when toggle format what by license comment
Oct 22, 2018 at 21:09 vote accept nagylzs
Oct 22, 2018 at 18:44 answer added pjh timeline score: 2
Oct 22, 2018 at 15:38 comment added nagylzs You are all saying that creating location independent code is a bad idea. The location of the script is the environment, and the script can use it. It just happens to be clumsy in bash. It proves that bash is not the perfect tool for the task. But it does not prove that location independent code is bad. Is there a good reason why not to write location independent code? I don't understand why "relative paths should be avoided"? Maybe they should be, but I need an explanation.
Oct 22, 2018 at 12:10 comment added chepner Typically, you avoid this by putting your code in well-known places when you install it, rather than making the script figure out what random directory you placed it in.
Oct 22, 2018 at 12:00 answer added Lewis M timeline score: 1
Oct 22, 2018 at 11:50 review Close votes
Oct 26, 2018 at 0:00
Oct 22, 2018 at 10:06 answer added Bsquare ℬℬ timeline score: 2
Oct 22, 2018 at 9:49 comment added Aserre I'm fairly sure you won't get better result than the question you linked. If you need to reuse the code, you could declare it in a system wide function or alias, or even just an external script you systematically call before your main script execution
Oct 22, 2018 at 9:24 comment added nagylzs These small scripts will be symlinked to ~/bin directories of various users on the system. So yes, reading symlinks is important.
Oct 22, 2018 at 9:10 comment added Socowi Most of the code is only there to resolve symlinks. Do you really need that? I think dirname "$0" should be sufficient in your case.
Oct 22, 2018 at 8:38 history asked nagylzs CC BY-SA 4.0