dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* builtin read -r and backslash-char escape sequences
@ 2015-08-03 16:37 John Marshall
  2015-08-03 17:03 ` Eric Blake
  2015-08-03 17:03 ` Harald van Dijk
  0 siblings, 2 replies; 4+ messages in thread
From: John Marshall @ 2015-08-03 16:37 UTC (permalink / raw)
  To: dash

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
$ bash -c 'read -r foo < backslashes; echo "$foo"' | cat -t
\a\t\x
$ ksh -c 'read -r foo < backslashes; echo "$foo"' | cat -t
\a\t\x

POSIX says of -r, "Do not treat a <backslash> character in any special way. Consider each <backslash> to be part of the input line" [1].  Translating them as escape sequences doesn't appear to be particularly compatible with this, but conceivably the translation is occurring at some other stage.

Is this the intended behaviour?

Thanks,

    John

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html#tag_20_109_04

-- 
 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. 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-04  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).