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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:37:03+00:00 2026-06-07T17:37:03+00:00

I have a script which you can pass test suites as parameters to: $

  • 0

I have a script which you can pass test suites as parameters to:

$ bash-specs a.suite b.suite

If the user doesn’t supply any test suites, all the test suites in the current folder shall be executed. This is how I do this currently:

local suites

if (($# > 0)); then
  suites=$@
else
  suites=*.suite
fi

This is an okay solution but I have a feeling there is a more elegant way. I basically look for some way to do a conditional assignment or setting a default value if no parameters are given.

  • 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-07T17:37:05+00:00Added an answer on June 7, 2026 at 5:37 pm

    I’d do this:

    if (( ! $# )); then
        set -- *.suite
    fi
    

    Now you have the filenames in $1, $2, etc. no matter whether the user specified them or let them default.

    Some notes:

    Your assignment to suites doesn’t seem to result in anything useful; it’s not an array, so you get either a string with space-separated file names, or the unexpanded glob "*.suites". I’m guessing you somehow wind up evaling that later on, but that’s a bad idea – any spaces or funky characters in the file names will screw things up. I recommend looping over the arguments and handling them individually, or using an actual array.

    If you use something like my snippet above, "$@" will expand to all the arguments, properly separated as if individually quoted. If you are going to be mucking with the arguments, you can save the original arguments in an array variable like so:

    suites=( "$@" )
    

    And then retrieve the whole thing (again, properly separated) with "${suites[@]}".

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

Sidebar

Related Questions

I have a Python3 script that can take optional command line parameters which the
I have a script which I can run perfectly if I call it manually
I have script which allows to display Bing search results. I can call for
I have a script which creates a user-defined object like this: obj = new
I have an api listener script which takes in get parameters. But I seem
I have a bash script which takes a single argument and returns around 8-10
I have a simple PHP script which generates a single email to a user
With window.open method I open new site with parameters, which I have to pass
i have a script which is for virtual keyboard, i am facing some problem
I have a script which validates each stage of a form and adds a

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.