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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:17:26+00:00 2026-05-31T05:17:26+00:00

With a view to a bug in git , at the moment git-submodule.sh reads

  • 0

With a view to a bug in git, at the moment git-submodule.sh reads (reordered):

[iterating over command line arguments]
        --reference)
            case "$2" in '') usage ;; esac
            reference="--reference=$2"
            shift
            ;;
        --reference=*)
            reference="$1"
            shift
            ;;
[...]
        if test -n "$reference"
        then
            git-clone $quiet "$reference" -n "$url" "$path" --separate-git-dir "$gitdir"
        else
            git-clone $quiet -n "$url" "$path" --separate-git-dir "$gitdir"
        fi ||
        die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")"

This uses only the last argument given by --reference. I now want to enhance this so that all --reference options are passed on to git-clone. This is trivial for trivial arguments (reference="$reference --reference=$2"), but my mind boggles when thinking about arguments containing white space, quote or shell meta characters.

What is the best practice to escape such accumulated arguments?

  • 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-05-31T05:17:26+00:00Added an answer on May 31, 2026 at 5:17 am

    Best practice would be to use a bash array:

    declare -a references
    #...
      --reference)
        case ... esac
        references+=("--reference=$2")
        shift
        ;;
      --reference=*)
        references+=("$1")
        shift
        ;;
    #...
    # no need to test the array for emptiness
    git-clone $quiet "${references[@]}" -n "$url" "$path" --separate-git-dir "$gitdir"
    

    However, the referenced script uses /bin/sh instead.

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

Sidebar

Related Questions

On a page of Java's Bug Database https://bugs.java.com/bugdatabase/view_bug?bug_id=4508058 it reads that Sun/Oracle will not
I have a really strange ‘bug’. I use this in my view: <% foreach
I have found an interesting bug in the android view-pager (r4 of the ACL).
That's a very common bug that happens to people who load a partial view
I have this form in my view: <!-- Bug (extra 'i') right here-----------v -->
I have this really weird bug. When I scroll down my table view, down
There is apparently a bug in Android which breaks View.bringToFront . If I have
I'm writing a custom view to get around the bug that displays the wrong
I want to view the diff of only two commits. For instance $ git
I had a small bug in a view and noticed that the view engine

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.