* A hyphen bug or not?
@ 2011-03-18 14:15 nix
2011-03-18 14:32 ` Mikael Magnusson
0 siblings, 1 reply; 3+ messages in thread
From: nix @ 2011-03-18 14:15 UTC (permalink / raw)
To: zsh-users
#!/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?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: A hyphen bug or not?
2011-03-18 14:15 A hyphen bug or not? nix
@ 2011-03-18 14:32 ` Mikael Magnusson
2011-03-18 17:21 ` nix
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2011-03-18 14:32 UTC (permalink / raw)
To: nix; +Cc: zsh-users
On 18 March 2011 15:15, <nix@myproxylists.com> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: A hyphen bug or not?
2011-03-18 14:32 ` Mikael Magnusson
@ 2011-03-18 17:21 ` nix
0 siblings, 0 replies; 3+ messages in thread
From: nix @ 2011-03-18 17:21 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh-users
> On 18 March 2011 15:15, <nix@myproxylists.com> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-18 17:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 14:15 A hyphen bug or not? nix
2011-03-18 14:32 ` Mikael Magnusson
2011-03-18 17:21 ` nix
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).