[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: realpath quoting




On 3/5/24 10:56, Max Nikulin wrote:
On 03/05/2024 09:19, Greg Wooledge wrote:
I still insist that this is a workaround that should *not*  be used
to try to cancel out quoting bugs in one's shell scripts.

There are still specific cases when quoting is necessary, e.g. ssh remote command (however you have to be sure concerning shell on the remote host).

In BASH printf has %q format. GNU coreutils supports it as well, but dash does not, so be careful.

Likely Jeremy's case does not really require this kind of quoting.

While "ls -l" output is for humans, realpath is often used in scripts. Certainly it should nor return quoted output by default. I am in doubts if a dedicated option should be added to realpath.


My use case is very simple. Give an argument to a program that expects a single filename/path.

If you give it an unquoted and unescaped filename it will break parsing the args thinking there are many.

When invoking from bash with auto completion the filename will get escaped as required. When cutting and pasting into a debugger prompt for args, not so.

The easy workaround for me is a few lines of python that emits a quoted filepath.


Reply to: