* Trailing whitespace after $'\0' with external commands
@ 2014-01-11 22:18 Eric Cook
2014-01-11 22:33 ` Eric Cook
2014-01-11 23:35 ` Bart Schaefer
0 siblings, 2 replies; 4+ messages in thread
From: Eric Cook @ 2014-01-11 22:18 UTC (permalink / raw)
To: zsh-users
I've noticed trailing whitespace is ignored when it appears immediately
after $'\0'. i am unsure if this is intended behavior or not.
% zsh -c "/usr/bin/printf '<%s>' $'\0'' '; echo"
<>
% zsh -c "printf '<%s>' $'\0'' '; echo"
< >
% ksh93 -c "/usr/bin/printf '<%s>' $'\0'' '; echo"
< >
% ksh93 -c "printf '<%s>' $'\0'' '; echo"
<
>
% ksh93 -c "type printf"
printf is a shell builtin
%
If the whitespace appears before the $'\0', it prints.
% zsh -c "/usr/bin/printf '<%s>' ' '$'\0'; echo"
< >
% zsh -c "printf '<%s>' ' '$'\0'; echo"
< >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Trailing whitespace after $'\0' with external commands
2014-01-11 22:18 Trailing whitespace after $'\0' with external commands Eric Cook
@ 2014-01-11 22:33 ` Eric Cook
2014-01-11 23:35 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Eric Cook @ 2014-01-11 22:33 UTC (permalink / raw)
To: zsh-users
On 01/11/2014 05:18 PM, Eric Cook wrote:
> % ksh93 -c "printf '<%s>' $'\0'' '; echo"
> <
>
% ksh93 -c "printf '<%s>' $'\0'' '; echo"
< >
mangled email :P
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Trailing whitespace after $'\0' with external commands
2014-01-11 22:18 Trailing whitespace after $'\0' with external commands Eric Cook
2014-01-11 22:33 ` Eric Cook
@ 2014-01-11 23:35 ` Bart Schaefer
2014-01-11 23:55 ` Eric Cook
1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2014-01-11 23:35 UTC (permalink / raw)
To: zsh-users
On Jan 11, 5:18pm, Eric Cook wrote:
} Subject: Trailing whitespace after $'\0' with external commands
}
} I've noticed trailing whitespace is ignored when it appears immediately
} after $'\0'. i am unsure if this is intended behavior or not.
}
} % zsh -c "/usr/bin/printf '<%s>' $'\0'' '; echo"
} <>
This is /usr/bin/printf behavior, not zsh behavior. Has nothing to do
with whitespace:
% zsh -fc "/usr/bin/printf '<%s>' $'\0''none of this'; echo"
<>
% zsh -fc "printf '<%s>' $'\0''none of this'; echo"
<none of this>
I can only conclude that ksh is not actually retaining the nul byte in
the argument list when calling /usr/bin/printf. There's an argument
(no pun intended) to be made for this behavior, in that it's impossible
for a string passed through the argv mechanism of execve and friends to
contain an embedded nul; the string will always end at that byte, so
ksh assumes it knows better than you and removes it so that the called
program (/usr/bin/printf in this case) can see the "whole" string.
Conversely, zsh is just doing *exactly* what you told it to do.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Trailing whitespace after $'\0' with external commands
2014-01-11 23:35 ` Bart Schaefer
@ 2014-01-11 23:55 ` Eric Cook
0 siblings, 0 replies; 4+ messages in thread
From: Eric Cook @ 2014-01-11 23:55 UTC (permalink / raw)
To: zsh-users
On 01/11/2014 06:35 PM, Bart Schaefer wrote:
> I can only conclude that ksh is not actually retaining the nul byte in
> the argument list when calling /usr/bin/printf. There's an argument
> (no pun intended) to be made for this behavior, in that it's impossible
> for a string passed through the argv mechanism of execve and friends to
> contain an embedded nul; the string will always end at that byte, so
> ksh assumes it knows better than you and removes it so that the called
> program (/usr/bin/printf in this case) can see the "whole" string.
>
> Conversely, zsh is just doing *exactly* what you told it to do.
Ah, thank you for explaining it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-11 23:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-11 22:18 Trailing whitespace after $'\0' with external commands Eric Cook
2014-01-11 22:33 ` Eric Cook
2014-01-11 23:35 ` Bart Schaefer
2014-01-11 23:55 ` Eric Cook
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).