LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2016, 04:26 AM   #1
dudengke
LQ Newbie
 
Registered: May 2016
Posts: 14

Rep: Reputation: Disabled
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?

Last edited by dudengke; 08-10-2016 at 02:07 AM.
 
Old 08-09-2016, 04:59 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
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.
 
Old 08-09-2016, 10:36 AM   #3
dudengke
LQ Newbie
 
Registered: May 2016
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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
 
Old 08-10-2016, 02:09 AM   #4
dudengke
LQ Newbie
 
Registered: May 2016
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash: Checking for lower case and upper case letters in a string fatalerror0x00 Programming 1 12-09-2012 02:17 AM
What is use of shopt command suboss87 Linux - General 2 08-30-2012 09:09 PM
Bash: change case graemef Programming 9 04-06-2010 08:48 PM
bash shopt -s not working for nocaseglob linuxcrazyguy Linux - Software 4 03-17-2007 03:05 PM
shopt command in zsh burninGpi Linux - Software 2 05-18-2006 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration