File tree 1 file changed +41
-3
lines changed 1 file changed +41
-3
lines changed Original file line number Diff line number Diff line change 481
481
fi
482
482
` ` `
483
483
484
- # ## Arguments
484
+ # # Positional Parameters
485
485
486
486
| Expression| Description|
487
487
| ----------| -----------|
492
492
| ` $_ ` | Last argument of the previous command|
493
493
494
494
>
495
- > \[ ! note\] ` $@ ` and ` $* ` must be quoted in order
496
- > Otherwise, they do exactly the same thing (arguments as separate strings)
495
+ > \[ ! note\] ` $@ ` and ` $* ` must be quoted; unquoted behavior is exactly the same i.e. args as separate strings
496
+
497
+ # ## `$@` vs `$*` Example
498
+
499
+ ` ` ` bash
500
+ print_params () {
501
+ echo " \$ 1 = $1 "
502
+ echo " \$ 2 = $2 "
503
+ echo " \$ 3 = $3 "
504
+ echo " \$ 4 = $4 "
505
+ }
506
+ pass_params () {
507
+ echo -e " \n" ' $* =>' ; print_params $*
508
+ echo -e " \n" ' "$*" =>' ; print_params " $* "
509
+ echo -e " \n" ' $@ =>' ; print_params $@
510
+ echo -e " \n" ' "$@" =>' ; print_params " $@ "
511
+ }
512
+
513
+ pass_params " word" " words with spaces"
514
+ $* =>
515
+ $1 = word
516
+ $2 = words
517
+ $3 = with
518
+ $4 = spaces
519
+ " $* " =>
520
+ $1 = word words with spaces
521
+ $2 =
522
+ $3 =
523
+ $4 =
524
+ $@ =>
525
+ $1 = word
526
+ $2 = words
527
+ $3 = with
528
+ $4 = spaces
529
+ " $@ " =>
530
+ $1 = word
531
+ $2 = words with spaces
532
+ $3 =
533
+ $4 =
534
+ ` ` `
497
535
498
536
# ## Special Parameters
499
537
You can’t perform that action at this time.
0 commit comments