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 4024634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:44:44+00:00 2026-05-20T10:44:44+00:00

Recently i got an assignment at school, where we are to write a small

  • 0

Recently i got an assignment at school, where we are to write a small program in Bash Scripting Language.

This shell script is supposed to accept some Positional Parameters or Arguments on the command line.

Now, with the help of an if-else statement i check if the argument is present, if the argument is present the script does what it is supposed to do, but if the argument is not present – i display an error message, prompting the user to input an argument and pass the argument again to the same shell script…

Now, i want to know if this approach is good or bad in Bash Programming paradigm. I’m slightly suspicious that this might run too many tasks in the background that are kept open or that are never ended and keep on consuming memory… please help.

Here’s a small snippet (assume the script name to be script1.bash):

 #!/bin/bash

 if [ $# -gt 0 ]; then
      read -p "Please enter your name: " name
      script1.bash $name
 elif [ $# -eq 1 ]; then
      echo "Your name is $1!"
 fi
  • 1 1 Answer
  • 3 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-05-20T10:44:45+00:00Added an answer on May 20, 2026 at 10:44 am

    It’s … questionable 🙂

    The main problem is that you’re spawning a subshell everytime someone refuses to input their name.

    You would be better of with something like:

    #!/bin/bash
    name=$1
    while [[ -z "$name" ]] ; do
        read -p "Please enter your name: " name
    done
    echo "Your name is $name!"
    

    which spawns no subshells.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did anybody know more information about this attack ? I recently got this script
recently got an issue when loading vs 2008, it displays this... can anyone tell
I recently got a shiny new development workstation. The only disadvantage of this is
Recently got this in my Event Log: A fatal hardware error has occurred. Reported
I recently got stuck in a situation like this: class A { public: typedef
I recently got an assignment to use the EXTEND OPEN command to add data
I recently got started trying to use SFML. For some reason my simple program
Well I recently got into PantherAds and got my ad script to place on
Recently got this following error in my application JPA/Hibernate with database Oracle RAC 11g.
I recently got an email from a customer saying that they were getting errors

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.