Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/StackUnix/status/771038971635834880
added 4 characters in body
Source Link
Rahul
  • 14k
  • 4
  • 46
  • 56

In a shell script, my understanding is that $@"$@" expands to the script arguments, quoting them as needed. For instance this forwards the script arguments to gcc:

gcc -fPIC "$@" 

When using the bash pass-to-stdin syntax <<< though, @$"@$" doesn't work as I would expect it to.

#!/bin/bash cat <<< "$@" 

Calling the script as ./test.sh foo "bar baz" gives

foo bar baz 

I would expect

foo "bar baz" 

Is there a way to write a shell script that prints it's arguments as you would write them on the shell prompt? For instance: a hint as to what command to use next, including the script arguments in the hint.

In a shell script, my understanding is that $@ expands to the script arguments, quoting them as needed. For instance this forwards the script arguments to gcc:

gcc -fPIC "$@" 

When using the bash pass-to-stdin syntax <<< though, @$ doesn't work as I would expect it to.

#!/bin/bash cat <<< "$@" 

Calling the script as ./test.sh foo "bar baz" gives

foo bar baz 

I would expect

foo "bar baz" 

Is there a way to write a shell script that prints it's arguments as you would write them on the shell prompt? For instance: a hint as to what command to use next, including the script arguments in the hint.

In a shell script, my understanding is that "$@" expands to the script arguments, quoting them as needed. For instance this forwards the script arguments to gcc:

gcc -fPIC "$@" 

When using the bash pass-to-stdin syntax <<< though, "@$" doesn't work as I would expect it to.

#!/bin/bash cat <<< "$@" 

Calling the script as ./test.sh foo "bar baz" gives

foo bar baz 

I would expect

foo "bar baz" 

Is there a way to write a shell script that prints it's arguments as you would write them on the shell prompt? For instance: a hint as to what command to use next, including the script arguments in the hint.

edited body
Source Link
Rahul
  • 14k
  • 4
  • 46
  • 56

In a shell script, my understanding is that "$@"$@ expands to the script arguments, quoting them as needed. For instance this forwards the script arguments to gcc:

gcc -fPIC "$@" 

When using the bash pass-to-stdin syntax <<< though, "@$"@$ doesn't work as I would expect it to.

#!/bin/bash cat <<< "$@" 

Calling the script as ./test.sh foo "bar baz" gives

foo bar baz 

I would expect

foo "bar baz" 

Is there a way to write a shell script that prints it's arguments as you would write them on the shell prompt? For instance: a hint as to what command to use next, including the script arguments in the hint.

In a shell script, my understanding is that "$@" expands to the script arguments, quoting them as needed. For instance this forwards the script arguments to gcc:

gcc -fPIC "$@" 

When using the bash pass-to-stdin syntax <<< though, "@$" doesn't work as I would expect it to.

#!/bin/bash cat <<< "$@" 

Calling the script as ./test.sh foo "bar baz" gives

foo bar baz 

I would expect

foo "bar baz" 

Is there a way to write a shell script that prints it's arguments as you would write them on the shell prompt? For instance: a hint as to what command to use next, including the script arguments in the hint.

In a shell script, my understanding is that $@ expands to the script arguments, quoting them as needed. For instance this forwards the script arguments to gcc:

gcc -fPIC "$@" 

When using the bash pass-to-stdin syntax <<< though, @$ doesn't work as I would expect it to.

#!/bin/bash cat <<< "$@" 

Calling the script as ./test.sh foo "bar baz" gives

foo bar baz 

I would expect

foo "bar baz" 

Is there a way to write a shell script that prints it's arguments as you would write them on the shell prompt? For instance: a hint as to what command to use next, including the script arguments in the hint.

deleted 28 characters in body
Source Link
Loading
edited title
Source Link
Loading
edited title
Source Link
Loading
edited title
Link
Loading
Source Link
Loading