Re: exec command and error checking

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

 



On 2014-01-28, at 05:16, Марк Коренберг wrote:

> $ dpkg -l | fgrep dash
> ii  dash                                   0.5.7-2ubuntu2
>                POSIX-compliant shell
> 
> $ exec 9<no_such_file && echo TEST
> dash: 1: cannot open no_such_file: No such file
> 
> $ exec 9<no_such_file || echo TEST
> dash: 2: cannot open no_such_file: No such file
> 
> So, I cannot test this operation without using $?
> 
> in BASH this works as expected (even in sh mode)
>  
o I believe POSIX (which I haven't read recently)
  allows, but does not require, failure of cd or
  redirection to terminate a noninteractive shell.
  (Were you trying your test interactively or in a
  script?)

o In various shells, I have become accustomed to $? being
  set only by wait() after exec() of a command.

I have become accustomed to dealing with this by coding:
    ( some_command <no_such_file ) && echo TEST
    ( some_command <no_such_file ) || echo TEST

I have never tried to deal with the failure of "exec redirection".

-- gil

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux