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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:49:04+00:00 2026-06-15T03:49:04+00:00

I get some strange behavior when trying to pass script parameters along to an

  • 0

I get some strange behavior when trying to pass script parameters along to an external program, in ksh.

My setup is like this :
– I have a ksh script (called “test”), that boils down to something like this :

...
args="$@"
java my_main_class $args
...

– If I call this script with something like :

> ./test "param1 param2" param3

…then the external application sees the following parameters : (param1, param2, param3)

  • If I change the script into something like :

    ...
    java my_main_class "$@"
    ...
    

…and do the same invocation, then my external application sees the following parameters (param1 param2, param3) – meaning that now, parameters are correctly seen.

Question : how can I modify my first version of the script, in order to correctly pass the parameters containing spaces, while still storing the “@$” into a variable, before external program invocation ?

Kind regards,
Andrei

  • 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-15T03:49:05+00:00Added an answer on June 15, 2026 at 3:49 am

    First, let’s setup the same session:

    $ set -- "param1 param2" param3
    $ echo $1, $2
    

    param1 param2, param3

    ksh and bash offer a valid solution with an array assignment:

    $ args=("$@")
    $ fake_java() { ( for w; do echo "$w"; done ); }
    

    This will still fail without quoting:

    $ fake_java ${args[@]}
    

    param1

    param2

    param3

    But quotes and array combined make this work:

    $ fake_java my_main_class "${args[@]}"
    

    param1 param2

    param3

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

Sidebar

Related Questions

I've come across some strange behavior trying to get files that start with a
I'm trying to remove the image border in ie, but I get some strange
I've been encountering some strange behavior when trying to find a key inside a
I am trying out the (latest) Android SDK, and noticed some strange behavior. I've
I get some strange behavior when sorting a c++ vector with at custom comparator
I have run into some strange behavior. I am not sure if this should
I stumbled across this very strange compiler behavior. I am trying to remove items
I see some strange behavior on the maximum heap size I get on Sun's
I'm currently doing some stuffs with Python and I get some strange behavior when
I'm having a strange problem with ZeroMQ, in which some messages get stuck, and

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.