ruby - python on OSX and echo -n -
context: ran this snippet on mac , noticed string -n sprinkled in garbled output. reply sh on ubuntu understands -n flag while sh on mac not.
as can see, python sending stdout string "-n abc\n" rather expected "abc".
is os.system phone call unable separate -n , abc? happens both zsh (the inverted % zsh's way of indicating eof) , bash, though if not mistaken no shells should invoked python-call (not because read says so, based on mutual sense) (edit: turns out i'm totally wrong , scheme runs subshell)
see how ruby does:
and more testing:
looks script sent sh environment variable shell @ point still zsh. makes sense. did nil clean out environment... maybe sh doesnt automatically set $shell.
the python docs state:
[os.system] implemented calling standard c function system()
follow through the man page c's system:
system() executes command specified in command calling /bin/sh -c command, , returns after command has been completed. during execution of command, sigchld blocked, , sigint , sigquit ignored.
emphasis mine.
the man page echo explains it:
some shells may provide builtin echo command similar or identical utility. notably, builtin echo in sh(1) not take -n option. consult builtin(1) manual page.
and can confirm yourself:
$ sh -c "echo -n hello" -n hello $ bash -c "echo -n hello" hello python ruby bash unix zsh
No comments:
Post a Comment