bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exec status with no command is 0 but no redirection


From: Bob Proulx
Subject: Re: exec status with no command is 0 but no redirection
Date: Fri, 14 May 2010 13:22:57 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

fpo wrote:
> Well, I am not sure it is a bug. I just tried this after reading the  
> manual page and the exec built-in command. I was expecting to have the  
> iconv command be called on the standard output of the shell script.

Thank you for the report.  But this is not a bug.  You are
misunderstanding how exec is to be used.  You have called it without
any command and without any redirections.  The way you are invoking it
doesn't seem useful to me.

> The script below outputs 0 as exec return status and the string is yet  
> given as ISO-8859-1. One of these is probably not correct though,

> exec | iconv -f ISO_8859-1 -t UTF-8

The 'exec' produces no output but the stdout is piped to 'iconv'.  The
'iconv' command reading no input from stdin produces no output.  The
status is success and $? is set to zero.

> shall we expect a status = 1 if no redirection is done?

No.  That is not an error.  It has its uses.  It would be a change
from traditional behavior and almost certain to break scripts.

exec without either command or redirections is not what you intended
to do here.  In that mode it is the same as 'true'.

  true | iconv -f ISO_8859-1 -t UTF-8

Beyond this I am not sure what you wanted to do with exec.  You may
have wanted this:

  exec iconv -f ISO_8859-1 -t UTF-8

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]