Re: builtin read -r and backslash-char escape sequences

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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. 
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux