-1

Can you explain what are (as I call it) "double sh calls", how they work and the advantages of such constructs ?

EDIT1 : Maybe an example can help you understand what I'm talking about.

$ set -- --no-resume-playback https://www.facebook.com/TBN/videos/1580372468665943/
$ sh -c 'echo $*'
$
$ sh -c 'echo $*' sh "$*"
--no-resume-playback https://www.facebook.com/TBN/videos/1580372468665943/

I couln't find any example of this in the man :

$ man bash | col -b | egrep "sh -c [\"']"
$

N.B.: If the title of my question is ambiguous, please help me change it because I don't know how to call such shell calls.

SebMa
  • 4,037
  • 29
  • 39
  • 2
    What is your question.? Are you just looking for understanding what `sh -c` is and how it works. If so your answer is at https://stackoverflow.com/q/23951346/5291015 – Inian Apr 09 '19 at 09:06
  • @Inian Nope. Please take a little more time and see my EDIT1 and the example below it so as to understand what I'm talking about. – SebMa Apr 09 '19 at 09:13
  • @Inian Please reconsider your down-vote and see my EDIT2 and the example below it that I've just updated, hope this helps make myself understood. – SebMa Apr 09 '19 at 09:24
  • I did NOT downvote your question – Inian Apr 09 '19 at 09:35

1 Answers1

2

man bash describes -c and its arguments:

If the -c option is present, then commands are read from the first non-option argument command_string. If there are arguments after the command_string, they are assigned to the positional parameters, starting with $0.

In this case, the command_string is echo $*, and the positional arguments are set in this way:

$0 = sh
$1 = "$*" = '--no-resume-playback https://www.facebook.com/TBN/videos/1580372468665943/'
choroba
  • 231,213
  • 25
  • 204
  • 289