Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:23:08+00:00 2026-06-14T16:23:08+00:00

I am working with a number of systems built of bash scripts and other

  • 0

I am working with a number of systems built of bash scripts and other tools.
Fairly often, I consider it good practice to use the -e, -u and -o pipefail options to catch error conditions and prevent unexpected behaviour.

However, some of the third party libraries (to which I have the ability to change source) do not do this, and are not happy with altering variable tests to exist with -u.

The scripts in those are likely to be sourced not executed. So what I’d like to do is in some of these, set a more permissive set of options, and then restore the stricter ones. Since the scripts in question are used by many users, some of whom have also encountered the same problem, I’d want to put this change into the third party scripts ie:

<preserve original options>
set +e +u +o pipefail
#do stuff like
if [ -n "$_UNSET_VAR" ] ; then
  cp <some stuff> <some other stuff>
fi
<restore original options (whatever they were)>

I am looking ways to preserve and restore these originals.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:23:09+00:00Added an answer on June 14, 2026 at 4:23 pm

    The special parameter $- contains a list of the options that are currently set. You can parse that to see if -e and -u are set. For pipefail, you’ll have to parse the output of shopt.

    If you can run your code in a subshell (you aren’t trying to set global variables and the like), it may be easier to do that and not worry about resetting the original state.

    (
        set +e +u +o pipefail
        if [ -n "$_UNSET_VAR" ]; then
           cp <some stuff> <some other stuff>
        fi
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a number of websites with files dating back to 2000.
I would like to separate my sigle-thread application to number of working threads. Just
I am working on a map with a number of mouse over ''points'' that
I've been working with .NET for a number of years, but recently I've been
I am working on porting a large number of .h and .lib files from
I have been working lately on a number of iterative algorithms in MATLAB, and
I am working on a large number adding program (without using biginteger class). I
Working with an undisclosed API, I found a function that can set the number
I'm working on a RIA system which has a huge number of static resources.
I need to use Python to download a large number of URLS, but they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.