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

  • SEARCH
  • Home
  • 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 8575901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:48:02+00:00 2026-06-11T19:48:02+00:00

In the script below, when the code inside the if statement is executed, the

  • 0

In the script below, when the code inside the if statement is executed, the user gets logged out from bash. Why is this?

#!/bin/sh  
if [ -z $1 ]; then  
   echo "1"  
   read w  
   exit 1  
fi  
if [ "$#" -gt "1" ]; then
   echo "1"
  read w
  exit 2
fi
export PTSUSER=$1.
<some more code>
  • 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-11T19:48:03+00:00Added an answer on June 11, 2026 at 7:48 pm

    If the script is sourced, and either of the if blocks are hit, then yes the current users bash shell will be exited, and the user will be logged out. This is due to sourcing a script will use the current users bash shell to execute the script.

    $ . ./script.sh
    

    On the other hand if it’s run in a new bash shell instance, then this won’t happen, and the bash instance will exit once either of the exit commands are executed in the shell (in either of the if blocks).

    $ bash ./script.sh
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the script code below to get results from my database based
The code below gets the username/password and runs it thru the backend.php script. <?php
I am using the below code for replacing a string inside a shell script.
I have placed the below code inside of the tag. <script type=text/javascript> jQuery(document).ready(function(){ jQuery('head').append('<script
Partial Code: My below code pulls a query from my DB and then uses
The code below was fully working when it was placed inside <script></script> tags on
I want to enable auto update script in flex3. i am using below code
Below is the complete code of the jquery AJAX tab script I am working
I have this code below which works fine but seems unnecessary as it loops
I have explained the problem below this code <div id='content'> <div id='help'> blah blah

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.