LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash: shopt -s lastpipe case errors (https://www.linuxquestions.org/questions/linux-newbie-8/bash-shopt-s-lastpipe-case-errors-4175586642/)

dudengke 08-09-2016 04:26 AM

bash: shopt -s lastpipe case errors
 
My file contain:
Code:

shopt -s lastpipe
exit 142 | false
echo $? -- ${PIPESTATUS[@]}

I run command: /bin/bash myfile
It output:
Code:

Hangup | false
129 -- 142 129

The correct should:
Code:

1 -- 142 1
When I run the above line by line in shell, it was correct.
why run it on a file, it failed?

pan64 08-09-2016 04:59 AM

would be nice to explain what you have executed line by line, not only the commands, but the results too.
you made at least a mistake in the first line (lastpipt is incorrect), anyway I do not really understand what did you try.

dudengke 08-09-2016 10:36 AM

Quote:

Originally Posted by pan64 (Post 5588356)
would be nice to explain what you have executed line by line, not only the commands, but the results too.
you made at least a mistake in the first line (lastpipt is incorrect), anyway I do not really understand what did you try.

Sorry, it is: shopt -s lastpipe

dudengke 08-10-2016 02:09 AM

Quote:

Originally Posted by pan64 (Post 5588356)
would be nice to explain what you have executed line by line, not only the commands, but the results too.
you made at least a mistake in the first line (lastpipt is incorrect), anyway I do not really understand what did you try.

Hi pan64

Thanks first! I just want to know why run above in a file, it would report

Code:

Hangup | false
I was testing the behave of shopt command.

//dudengke


All times are GMT -5. The time now is 12:29 AM.