Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A hyphen bug or not?
- X-seq: zsh-users 15882
- From: nix@xxxxxxxxxxxxxxxx
- To: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- Subject: Re: A hyphen bug or not?
- Date: Fri, 18 Mar 2011 19:21:00 +0200
- Cc: zsh-users@xxxxxxx
- Importance: Normal
- In-reply-to: <AANLkTimBkrj=PFb4XTdNarrnH=0nKERw-JTxQ3HcZ0GQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <e26a5685bd1c61bc2c25f82c387ccb7c.squirrel@gameframe.net> <AANLkTimBkrj=PFb4XTdNarrnH=0nKERw-JTxQ3HcZ0GQ@mail.gmail.com>
> On 18 March 2011 15:15, <nix@xxxxxxxxxxxxxxxx> wrote:
>> #!/bin/zsh
>>
>> emulate zsh
>>
>> R="-"
>>
>> echo "$R" # <--- its empty here as well !
>>
>> R=$(echo "$R" | base64)
>> R=$(print ${R//$'\n'})
>>
>> echo "R: $R" # <--- this is wrong, it should be a hyphen -
>>
>> # When we change the "R" variable to a octal presentation of hyphen
>>
>> R="\055"
>> R=$(echo "$R" | base64)
>> R=$(print ${R//$'\n'})
>>
>> echo "R: $R" # <--- now it works and base64 decod returns a hyphen "-"
>> as
>> it should.
>>
>>
>> How I can echo a hyphen without echoing octal?
>
> Your problem is that echo actually interprets options, if you want to
> echo arguments starting with a hyphen you should use echo - "arguments
> here" (it's always safe to add the leading hyphen to separate options
> from arguments). If you also don't want to interpret escapes, use echo
> -E - "arguments here".
>
> --
> Mikael Magnusson
>
R="-"
echo - "$R" did the trick.
Thank you.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author