1

I need to demonstrate the order in which command substitution, variable substitution and globbing occurs. Any ideas on how to do it?

Mat
  • 202,337
  • 40
  • 393
  • 406
SharkTiles
  • 585
  • 3
  • 9
  • 22
  • Unfortunately I've got no clue about it. I know what they mean individually. For example I know how to demonstrate variable substitution, command substitution etc., but I have no clue on how to demonstrate their order of execution. Sorry I'm totally new to this subject :( – SharkTiles Jun 12 '12 at 03:02
  • try searching for "order of evaluation" . good luck. – shellter Jun 12 '12 at 03:03
  • 1
    http://www.gnu.org/software/bash/manual/bashref.html#Shell-Expansions – nhahtdh Jun 12 '12 at 03:07

1 Answers1

1
  • Command substitution < globbing

    ls $(echo '*')
    

    Otherwise, * would not have been expanded.

  • variable expansion (not substitution) < globbing

    x='*' ; ls $x
    

    Same reason as above.

  • variable expansion and command substitution appear at the same time, left to right. If you can think of a good example, leave me a comment, I have no ideas.
choroba
  • 231,213
  • 25
  • 204
  • 289
  • We might conclude that variable expansion and command substitution are done in the same workstep if we can see that neither (a) variable expansion occurs after command substitution nor (b) command substitution occurs after variable expansion. (a) `echo \`echo $\`x # $x <=> no variable expansion` (b) `c='\`ls\`';echo $c # \`ls\` <=> no command substitution` – Armali Nov 21 '13 at 07:15