dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Marshall <john.marshall@sanger.ac.uk>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: dash@vger.kernel.org
Subject: Re: builtin read -r and backslash-char escape sequences
Date: Tue, 4 Aug 2015 10:56:39 +0100	[thread overview]
Message-ID: <A73736EB-F742-4F31-A48B-4C4816C5212B@sanger.ac.uk> (raw)
In-Reply-To: <55BF9EE6.8050407@gigawatt.nl>

On 3 Aug 2015, at 18:03, Harald van Dijk wrote:
> On 03/08/2015 18:37, John Marshall wrote:
>> Problems with one of my scripts appear to have been caused by dash's read -r translating escape sequences (like \t) whereas several other shells read them literally.  For example:
>> 
>> $ printf '%s' '\a\t\x' > backslashes
>> $ dash -c 'read -r foo < backslashes; echo "$foo"' | cat -t
>> ^G^I\x
> 
> You're using echo to print what gets assigned to foo, but backslashes are not portable with echo. You probably noticed that already since you're using printf to determine what gets saved in the backslashes file.

D'oh!  Indeed I noticed that when the backslashes were right there, but to really internalise it I guess one has to find out the hard way -- which I have now done.  The real script eventually evals the line rather than echoing it, but there's a cmd=`echo $cmd | sed ...` along the way that does the damage.

Thanks to both of you,

    John

-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 

      reply	other threads:[~2015-08-04  9:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 16:37 builtin read -r and backslash-char escape sequences John Marshall
2015-08-03 17:03 ` Eric Blake
2015-08-03 17:03 ` Harald van Dijk
2015-08-04  9:56   ` John Marshall [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A73736EB-F742-4F31-A48B-4C4816C5212B@sanger.ac.uk \
    --to=john.marshall@sanger.ac.uk \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).