-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
close() on pipe command does not return exit status #203
Comments
Creates the iostream.go file. Use I/O stream interfaces for all file redirects and command pipes. Fixes benhoyt#203 Fixes benhoyt#204
Interesting! Linking the GAWK docs on this for reference. For comparison, POSIX just says "If the close was successful, the function shall return zero; otherwise, it shall return non-zero." |
Ah nice! Those linked docs explain plan9 awk's behavior:
It complains about an illegal statement. But yeah this is definitely an undocumented easter egg! |
Creates the iostream.go file. Use I/O stream interfaces for all file redirects and command pipes. Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file. Use I/O stream interfaces for all file redirects and command pipes. Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file. Use I/O stream interfaces for all file redirects and command pipes. Mimicks gawk's behavior for the result of the `close' builtin function when the argument to close() is a pipe: 1. the value passed to exit() when process exits normally 2. 256 + signal code when process exits due to signal 3. 512 + signal code when process exits due to signal with a core dump Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file. Use I/O stream interfaces for all file redirects and command pipes. Mimicks gawk's behavior for the result of the `close' builtin function when the argument to close() is a pipe: 1. the value passed to exit() when process exits normally 2. 256 + signal code when process exits due to signal 3. 512 + signal code when process exits due to signal with a core dump Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file and uses I/O stream interfaces for all file redirects and command pipes. Defines inputStream and outputStream interfaces which satisfy the io.ReadCloser and io.WriteCloser interfaces, respectively. Adds an additional .ExitCode() accessor to return the exit code for goawk's close() builtin function. When the argument to close() is a pipe, this mimicks gawk's behavior: 1. the value passed to exit() when process exits normally 2. 256 + signal code when process exits due to signal 3. 512 + signal code when process exits due to signal with a core dump Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file and uses I/O stream interfaces for all file redirects and command pipes. Defines inputStream and outputStream interfaces which satisfy the io.ReadCloser and io.WriteCloser interfaces, respectively. Adds an additional .ExitCode() accessor to return the exit code for goawk's close() builtin function. When the argument to close() is a pipe, this mimicks gawk's behavior: 1. the value passed to exit() when process exits normally 2. 256 + signal code when process exits due to signal 3. 512 + signal code when process exits due to signal with a core dump Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file and uses I/O stream interfaces for all file redirects and command pipes. Defines inputStream and outputStream interfaces which satisfy the io.ReadCloser and io.WriteCloser interfaces, respectively. Adds an additional .ExitCode() accessor to return the exit code for goawk's close() builtin function. When the argument to close() is a pipe, this mimicks gawk's behavior: 1. The value passed to exit() when process exits normally 2. 256 + signal code when process exits due to signal 3. 512 + signal code when process exits due to signal with a core dump Fixes benhoyt#203 Fixes benhoyt#204
Creates the iostream.go file and uses I/O stream interfaces for all file redirects and command pipes. Defines inputStream and outputStream interfaces which satisfy the io.ReadCloser and io.WriteCloser interfaces, respectively. Adds an additional .ExitCode() accessor to return the exit code for goawk's close() builtin function. When the argument to close() is a pipe, this mimicks gawk's behavior: 1. The value passed to exit() when process exits normally 2. 256 + signal code when process exits due to signal 3. 512 + signal code when process exits due to signal with a core dump Fixes benhoyt#203 Fixes benhoyt#204
An undocumented feature of other awks is to have the
close()
builtin function return the exit status of the process which was opened by the pipe. Theclose()
builtin for goawk always returns -1 for output pipes and always returns 0 for input pipes.Example
Portability?
Different awks also have various implementations. The same example above was run for ...
edit: Removed duplicate rows. I also remembered how the
wait()
result shifts the exit code.The text was updated successfully, but these errors were encountered: