Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by Joel_Mckay

8 hours ago

In most use cases, the bash scripts location is more important than $HOME. This is because it is resilient to changes in user in the session, and parent process current working location contexts. =3

scriptPath=$(/usr/bin/realpath "${BASH_SOURCE[0]}")

localPath=$(/usr/bin/dirname "$scriptPath" )

/usr/bin/echo "localPath = '$localPath'"

0 comments

Joel_Mckay

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities