Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
How to get the path of a sourced Bourne shell script?

In Bash, the correct way to get the full path to a shell script is ${BASH_SOURCE[0]}, since $0 returns bash if the script is being sourced. For example, try running this in your terminal:

source <(echo 'echo $0')

It will print bash.

Does anyone know how to do this for Bourne shell scripts? For example, what would be the contents of a script foo such that if I typed this:

sh -c '. foo'

it would output the full path to the script?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!