Re: realpath quoting

2024-05-04 Thread Greg Wooledge
On Sat, May 04, 2024 at 08:22:27AM -0500, Tom Browder wrote: > $ cat read.raku > #!/usr/bin/env raku > my $a = "name with spaces"; > my $b = "name\nwith newline"; > say "file 1: |$a|"; > say "file 2: |$b|"; > > And executing it: > > $ ./read.raku > file 1: |name with spaces| > file 2: |name >

Re: realpath quoting

2024-05-04 Thread Tom Browder
On Fri, May 3, 2024 at 21:43 David Christensen wrote: ... > My practice is to start with '#!/bin/sh' and migrate to '#!/usr/bin/env > perl' as complexity increases. I agree with David's direction, but ending with Raku instead of Perl. I don't think golfing is the way to illustrate a practical

Re: realpath quoting

2024-05-04 Thread DdB
Am 03.05.2024 um 21:11 schrieb David Christensen: > I can obviously add an extra step to the process to convert the new file > name to something acceptable before processing. However, my question was > how to avoid that extra step by getting fully quoted filenames to process. Today, on linux, i

Re: realpath quoting

2024-05-04 Thread DdB
Am 03.05.2024 um 21:11 schrieb David Christensen: > I can obviously add an extra step to the process to convert the new file > name to something acceptable before processing. However, my question was > how to avoid that extra step by getting fully quoted filenames to process. Not sure, if i get

Re: realpath quoting

2024-05-03 Thread David Christensen
On 5/3/24 04:34, jeremy ardley wrote: On 3/5/24 19:06, Greg Wooledge wrote: I would suggest that if you need to use a debugger to track down a bug in your program, you should use filenames that don't require quoting when you set up your tests. 1970's style static test cases are not relevant

Re: realpath quoting

2024-05-03 Thread David Christensen
On 5/3/24 04:09, Greg Wooledge wrote: On Thu, May 02, 2024 at 10:18:03PM -0700, David Christensen wrote: I am unable to find $'string' in the dash(1) man page (?). As I typically write "#!/bin/sh" shell scripts, writing such to deal with file names containing non-printing characters is going

Re: realpath quoting

2024-05-03 Thread Max Nikulin
On 03/05/2024 11:31, jeremy ardley wrote: My use case is very simple. Give an argument to a program that expects a single filename/path. Role of realpath in your workflow is not clear for me yet. If you need to copy its result to clipboard then you may use xsel, xclip, etc. realpath --zero

Re: realpath quoting

2024-05-03 Thread Sirius
In days of yore (Fri, 03 May 2024), jeremy ardley thus quoth: > > On 3/5/24 19:06, Greg Wooledge wrote: > > I would suggest that if you need to use a debugger to track down a bug > > in your program, you should use filenames that don't require quoting > > when you set up your tests. > > 1970's

Re: realpath quoting

2024-05-03 Thread jeremy ardley
On 3/5/24 19:06, Greg Wooledge wrote: I would suggest that if you need to use a debugger to track down a bug in your program, you should use filenames that don't require quoting when you set up your tests. 1970's style static test cases are not relevant here. In the real world...  I

Re: realpath quoting

2024-05-03 Thread Greg Wooledge
On Thu, May 02, 2024 at 10:18:03PM -0700, David Christensen wrote: > I am unable to find $'string' in the dash(1) man page (?). As I typically > write "#!/bin/sh" shell scripts, writing such to deal with file names > containing non-printing characters is going to baffle me. Currently, $' quoting

Re: realpath quoting

2024-05-03 Thread Greg Wooledge
On Fri, May 03, 2024 at 12:31:13PM +0800, jeremy ardley wrote: > My use case is very simple. Give an argument to a program that expects a > single filename/path. Then you need to use "$1" with quotes when you reference it. Simple! > If you give it an unquoted and unescaped filename it will

Re: realpath quoting

2024-05-02 Thread David Christensen
On 5/2/24 19: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 +1

Re: realpath quoting

2024-05-02 Thread David Christensen
On 5/2/24 19:19, Greg Wooledge wrote: On Thu, May 02, 2024 at 07:11:46PM -0700, David Christensen wrote: Perhaps Perl and the module String::ShellQuote ? 2024-05-02 18:50:28 dpchrist@laalaa ~ $ touch "name with spaces" 2024-05-02 18:50:45 dpchrist@laalaa ~ $ touch "name with\nnewline" You

Re: realpath quoting

2024-05-02 Thread Teemu Likonen
* 2024-05-03 06:59:37+0800, jeremy ardley wrote: > I have a need  to get the full path of a file that has spaces in its > name to use as a program argument > jeremy@client:~$ realpath name\ with\ spaces > /home/jeremy/name with spaces > Can realpath or other utility return a quoted pathname?

Re: realpath quoting

2024-05-02 Thread jeremy ardley
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

Re: realpath quoting

2024-05-02 Thread Max Nikulin
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

Re: realpath quoting

2024-05-02 Thread Greg Wooledge
On Thu, May 02, 2024 at 07:11:46PM -0700, David Christensen wrote: > Perhaps Perl and the module String::ShellQuote ? > > 2024-05-02 18:50:28 dpchrist@laalaa ~ > $ touch "name with spaces" > > 2024-05-02 18:50:45 dpchrist@laalaa ~ > $ touch "name with\nnewline" You didn't create a name with a

Re: realpath quoting

2024-05-02 Thread David Christensen
On 5/2/24 15:59, jeremy ardley wrote: I have a need  to get the full path of a file that has spaces in its name to use as a program argument e.g. jeremy@client:~$ ls -l name\ with\ spaces -rw-r--r-- 1 jeremy jeremy 0 May  3 06:51 'name with spaces' jeremy@client:~$ realpath name\ with\ spaces

Re: realpath quoting

2024-05-02 Thread Greg Wooledge
On Fri, May 03, 2024 at 07:42:20AM +0800, jeremy ardley wrote: > > On 3/5/24 07:29, Greg Wooledge wrote: > > > The spaces without quotes cause problems with subsequent processing. > > Then the subsequent processing has bugs in it. Fix them. > > > > > Can realpath or other utility return a

Re: realpath quoting

2024-05-02 Thread jeremy ardley
On 3/5/24 07:29, Greg Wooledge wrote: The spaces without quotes cause problems with subsequent processing. Then the subsequent processing has bugs in it. Fix them. Can realpath or other utility return a quoted pathname? That would be extremely counterproductive. Do not look for kludges to

Re: realpath quoting

2024-05-02 Thread Greg Wooledge
On Fri, May 03, 2024 at 06:59:37AM +0800, jeremy ardley wrote: > I have a need  to get the full path of a file that has spaces in its name to > use as a program argument > > e.g. > > jeremy@client:~$ ls -l name\ with\ spaces > -rw-r--r-- 1 jeremy jeremy 0 May  3 06:51 'name with spaces' >

Re: realpath quoting

2024-05-02 Thread DdB
Am 03.05.2024 um 00:59 schrieb jeremy ardley: > I have a need  to get the full path of a file that has spaces in its > name to use as a program argument > > e.g. > > jeremy@client:~$ ls -l name\ with\ spaces > -rw-r--r-- 1 jeremy jeremy 0 May  3 06:51 'name with spaces' > jeremy@client:~$

realpath quoting

2024-05-02 Thread jeremy ardley
I have a need  to get the full path of a file that has spaces in its name to use as a program argument e.g. jeremy@client:~$ ls -l name\ with\ spaces -rw-r--r-- 1 jeremy jeremy 0 May  3 06:51 'name with spaces' jeremy@client:~$ realpath name\ with\ spaces /home/jeremy/name with spaces The