Skip to content

Instantly share code, notes, and snippets.

View jay3126's full-sized avatar

Janmejay Rai (Jay) jay3126

View GitHub Profile
@Jeff-Russ
Jeff-Russ / Study: Multi-File Bash Scripting and Paths.md
Last active August 9, 2016 06:23
Study: including other bash scripts from relative paths and absolute paths

Bash Scripting:

Managing Pathnames in Multi-file Bash Projects

Paths can get somewhat muddled up when you execute a Bash script with dependencies. Each script, when executed, is executed at a certain location as demonstrated by echoing pwd from the script. This is the directory assumed if ever you try to source (aka .) from that script.

This location is subject to change as it traces back to the ORIGINAL caller. By "ORIGINAL" I don't mean the location script that called it, or even the location of the script that called the script that called it, I mean the working directory of the first to initiate the chain of calls, which might be the user in the terminal or the location of the clicked executable.

Thing to consider:

  1. The caller's location