Article View: linux.debian.user
Article #562Re: escaping with \ in shells (was: beeps and other sounds)
From: Vincent Lefevre
Date: Tue, 17 Nov 2026 02:40
Date: Tue, 17 Nov 2026 02:40
34 lines
3006 bytes
3006 bytes
On 2026-11-16 15:53:51 +0100, Nicolas George wrote: > Vincent Lefevre (HE12026-11-16): > > I would have said that backslash + ASCII letter ([A-Za-z]) inside > > double quotes is safe (probably with digits too) as used in many > > scripts, and such characters are obviously not characters that need > > escaping. > > Why would it be OBVIOUS that the shell do not use the same escaping > sequences as printf or the C language? Contrary to the escape sequences in C, the purpose of backslash in a shell is to "preserve the literal value of the following character". Doing otherwise would be a source of confusion. > > There are cases when one wants to be able to do expansion, knowing > > that this is safe. For instance: > > Yes, but what is your point? Using single quotes is not possible in these cases. $ printf "$?\n" 0 but $ printf '$?\n' $? -- Vincent Lefรจvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Technical Details
Message-ID:
<O0hgZ-cmZn-1@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!bofh.it!news.nic.it!robomodReferences:
<O04tr-cfJv-27@gated-at.bofh.it> <O04jL-cfFg-3@gated-at.bofh.it> <O05zb-cgt7-1@gated-at.bofh.it> <O06lz-cgMk-3@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!bofh.it!news.nic.it!robomod From: Vincent Lefevre <vincent@vinc17.net> Newsgroups: linux.debian.user Subject: Re: escaping with \ in shells (was: beeps and other sounds) Date: Tue, 17 Nov 2026 03:40:01 +0100 Message-ID: <O0hgZ-cmZn-1@gated-at.bofh.it> References: <O04tr-cfJv-27@gated-at.bofh.it> <O04jL-cfFg-3@gated-at.bofh.it> <O05zb-cgt7-1@gated-at.bofh.it> <O06lz-cgMk-3@gated-at.bofh.it> X-Original-To: debian-user@lists.debian.org X-Mailbox-Line: From debian-user-request@lists.debian.org Tue Nov 17 02:33:32 2026 Old-Return-Path: <vincent@vinc17.net> X-Amavis-Spam-Status: No, score=-1.9 tagged_above=-10000 required=5.3 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham autolearn_force=no X-Policyd-Weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -4.6 Mail-Followup-To: debian-user@lists.debian.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.4.3+67 (b2844dd7) vl-188789 (2026-11-11) X-Mailing-List: <debian-user@lists.debian.org> archive/latest/832950 List-ID: <debian-user.lists.debian.org> List-URL: <https://lists.debian.org/debian-user/> List-Archive: https://lists.debian.org/msgid-search/20261117023317.GB803748@qaa.vinc17.org Approved: robomod@news.nic.it Lines: 34 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Tue, 17 Nov 2026 03:33:17 +0100 X-Original-Message-ID: <20261117023317.GB803748@qaa.vinc17.org> X-Original-References: <avr8-gKZTx-g27RE@wooledge.org> <avr6OuVs_c90AmCM@phare.normalesup.org> <20261116140728.GA803748@qaa.vinc17.org> <avsY_5TT0NYprhPQ@phare.normalesup.org>