helpThe GNU Bourne-Again SHell - Support: sr #108576, Bash should support file:// URLs...

 
 

sr #108576: Bash should support file:// URLs as regular paths

Submitted by:  Dan McDougall <riskable>
Submitted on:  Tue 20 May 2014 01:25:25 PM UTC  
 
Category: NonePriority: 5 - Normal
Severity: 1 - WishStatus: None
Privacy: PublicAssigned to: None
Open/Closed: OpenOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 20 May 2014 01:25:25 PM UTC, original submission:

It occurred to me today that when copying and pasting a file from a graphical tool into a terminal it will almost always be pasted as file:///some/path instead of just /some/path. I would fault the GUIs for this incompatibility but really, file:// URLs have been a standard for quite some time now.

I propose that support for file:// URLs be added bash's built in commands such as 'cd', 'exec', etc and similar path-using capabilities (e.g. $PATH, '-f' in conditionals). Examples of how it would work:

cd file:///usr/bin # Same as cd /usr/bin
cd file://~/bin # cd ~/bin
exec file:///usr/local/bin/foo # exec /usr/local/bin/foo
file:///bin/ls # Execute /bin/ls
[[ -f file:///etc/passwd ]] && echo "/etc/passwd exists"

Really, the only thing that needs to happen from the shell's perspective is the removal of the leading 'file://' part of the string. It would be extra awesome if file:// URLs worked in the $PATH variable as well but that would just be "extra credit" since the most common use case would be simple things like 'cd' and execution.

To handle the edge case where a file or directory's name (in the current working directory) starts with "file://" it would require escaping anyway so that situation should be easily distinguished:

touch 'file://'
[[ -f file:\/\/ ]] && echo "the file, 'file://' exists"
mkdir 'file://' && cd file:\/\/

The purpose of this wish is simply to improve the user experience. There's no absolute technical reason for this feature to exist other than, "it would be nice" and perhaps make it easier for certain kinds of external programs to interact with the shell.

Dan McDougall <riskable>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by riskable (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup