mainThe GNU Bourne-Again SHell - Support: sr #110684, Feature request: shorthand for...


sr #110684: Feature request: shorthand for relative paths in bash scripts

Submitter:  Brad <bradoz>
Submitted:  Sun 03 Jul 2022 12:40:09 AM UTC
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Wont Do
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup

Tue 17 Jan 2023 10:52:50 PM UTC, comment #4: 

You should be able to use ${BASH_SOURCE[0]} and decompose it into a directory name and a file name however you like. For example:

case ${BASH_SOURCE[0]} in
/*/*|./*|../*) _DIR_=${BASH_SOURCE[0]%/*} _FILE_=${BASH_SOURCE[0]##*/} ;;
/*) _DIR_=/ _FILE_=${BASH_SOURCE##*/} ;;
/) _DIR_=$PWD/${BASH_SOURCE[0]%/*} _FILE_=${BASH_SOURCE[0]##*/} ;;

Is there some advantage to having these done internally than using code like the above? I get the impulse not to have to write that code yourself, but is that enough of a reason to add them to bash itself?

Chet Ramey <chet>
Group administrator
Wed 06 Jul 2022 03:36:03 AM UTC, comment #3: 

ok 3 attempts to comment and add a file lol this website has some issues.

I emailed the original message to bug-bash and I also attached it here as an md file.

PS - if you need help upgrading this site let me know I am a PHP ninja.

(file #53401)

Brad <bradoz>
Tue 05 Jul 2022 01:27:22 PM UTC, comment #2: 

If you still have the original text, send it to -email is unavailable- or

More people will see it, and it will still get archived.

I don't know exactly what this post was about, so I can't say for sure, but I suspect that help-bash users will be able to give you suggestions about what you want to do using existing bash mechanisms.

Chet Ramey <chet>
Group administrator
Sun 03 Jul 2022 02:11:21 AM UTC, comment #1: 

Just came for a look and seems like the entire post I wrote got chopped off?
Under original submission, it only has two lines of text when there were about 10 paragraphs with code examples.

Brad <bradoz>
Sun 03 Jul 2022 12:40:09 AM UTC, original submission:  

Hey, guys I just joined to ask this please forgive me if I am in the wrong place.

First of all big fan of bash, I use it a LOT

Brad <bradoz>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #53401: added by bradoz (3KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by bradoz (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-17 chet StatusPostponed Wont Do
    2022-07-06 bradoz Attached File- Added, #53401
    2022-07-05 chet StatusNone Postponed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code