Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #269169
| From | David Christensen <dpchrist@holgerdanske.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: realpath quoting |
| Date | 2024-05-03 07:40 +0200 |
| Message-ID | <IzTOi-aJfj-13@gated-at.bofh.it> (permalink) |
| References | <IzNIR-aFv9-1@gated-at.bofh.it> <IzQGJ-aHiZ-1@gated-at.bofh.it> <IzQGJ-aHiZ-3@gated-at.bofh.it> <IzRjr-aHve-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
> (however you have to be sure concerning shell on the
> remote host).
+1
> In BASH printf has %q format. GNU coreutils supports it as well, but
> dash does not, so be careful.
My practice is to start with '#!/bin/sh' and migrate to '#!/usr/bin/env
perl' as complexity increases.
> Likely Jeremy's case does not really require this kind of quoting.
We need to see the full range of file names the OP is trying to deal with.
> 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.
Thank you for helping me realize that my solution fails to print the
resolved absolute file name. Here is the updated solution:
2024-05-02 21:57:56 dpchrist@laalaa ~
$ touch 'name with spaces'
2024-05-02 22:23:01 dpchrist@laalaa ~
$ touch 'name with
> newline'
2024-05-02 22:28:36 dpchrist@laalaa ~
$ perl -MString::ShellQuote '-MFile::Spec::Functions qw(rel2abs)' -e
'print shell_quote(map { rel2abs $_ } @ARGV), "\n"' name*
'/home/dpchrist/name with
newline' '/home/dpchrist/name with spaces'
David
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 01:10 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 01:40 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 01:50 +0200
Re: realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 01:50 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 04:20 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 04:20 +0200
Re: realpath quoting Max Nikulin <manikulin@gmail.com> - 2024-05-03 05:00 +0200
Re: realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 06:40 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 13:10 +0200
Re: realpath quoting jeremy ardley <jeremy.ardley@gmail.com> - 2024-05-03 13:40 +0200
Re: realpath quoting Sirius <sirius@trudheim.com> - 2024-05-03 13:50 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 21:20 +0200
Re: realpath quoting Max Nikulin <manikulin@gmail.com> - 2024-05-03 17:20 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 07:40 +0200
Re: realpath quoting Tom Browder <tom.browder@gmail.com> - 2024-05-04 15:30 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-04 16:00 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 07:20 +0200
Re: realpath quoting Greg Wooledge <greg@wooledge.org> - 2024-05-03 13:10 +0200
Re: realpath quoting David Christensen <dpchrist@holgerdanske.com> - 2024-05-03 20:50 +0200
Re: realpath quoting Teemu Likonen <tlikonen@iki.fi> - 2024-05-03 06:50 +0200
csiph-web