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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:16:46+00:00 2026-06-09T21:16:46+00:00

Google has finally failed me. I cannot seem to find how to do this

  • 0

Google has finally failed me. I cannot seem to find how to do this in Bourne shell scripting:

I am writing a shell script to handle all of my testing for a project. I’ve set up functions for each task that this script could do (build, run, clean, etc), and would like to pass any additional command-line parameters (besides the command itself) onto the desired function.

Example:

./test.sh build -j should pass -j into the build function.

A pseudo-code version of this logic would look like:

function build() {
   make $*
}

if [ $1 == 'build' ]; then
   build $2 -> $N
fi

How can I accomplish this?

  • 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-09T21:16:48+00:00Added an answer on June 9, 2026 at 9:16 pm

    I think you could achieve this effect using the shift command. It will move all of the positional parameters down one place and drops the value of $1 (so the value of $3 gets moved to $2, the value of $2 gets moved to $1 and the value of $1 is lost). Once you’ve done that you can just use $@ to pick up the list of arguments you’re actually interested in e.g.

    function build() {
        echo "build with $@"
    }
    
    echo "Starting args are $@"
    cmd=$1
    shift
    
    if [ "$cmd" = 'build' ]; then
        build "$@"
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was going through this sample package which Google has provided with it's sdk.
Finally, I find some article in http://code.google.com/intl/en/web/ajaxcrawling/docs/getting-started.html msnbc use this method. Thanks for all
I've gone bonkers hitting Stackflow and Google trying to find solutions, and finally am
Google has taken up the implementation of WebRTC in Chrome very seriously as indicated
Google has an example on analytic data for mobile devices. The code is provided
Does Google has a service similar to Yahoo! Placemaker: Developers specify structured and unstructured
It is known that google has best searching & indexing algorithm. The also have
I was wondering if it is possible that Google has a feature to view
I'm talking about the knowledge graph concept google has recently incorporated to google search.
I have recently indexed my website. Google has indexed the main site as: www.site.com/?ref=old

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.