Skip to content

Instantly share code, notes, and snippets.

@josepsmartinez
Last active March 21, 2022 13:27
Show Gist options
  • Save josepsmartinez/522f627d88bd71c2c6089ca9de9260b7 to your computer and use it in GitHub Desktop.
Save josepsmartinez/522f627d88bd71c2c6089ca9de9260b7 to your computer and use it in GitHub Desktop.
Safe practice for attributing a script's directory UNIX path to a shell variable [Reference: https://stackoverflow.com/posts/4774063/revisions (2020/12/27)]
#!/bin/bash
SCRIPTPATH=$( cd $(dirname $0) >/dev/null 2>&1 ; pwd -P )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment