Flash Notes
Commands - Command interpreter
• How is the $* bash parameter interpreted, outside double quotes ?
Test script
#!/bin/bash show_args() { args $* } show_args UNIX "Linus Torvalds" "GNU : GNU is Not Unix"
Result
ARGC = 10 ARGV[ 1 : length = 4] = "UNIX" ARGV[ 2 : length = 5] = "Linus" ARGV[ 3 : length = 8] = "Torvalds" ARGV[ 4 : length = 3] = "GNU" ARGV[ 5 : length = 1] = ":" ARGV[ 6 : length = 3] = "GNU" ARGV[ 7 : length = 2] = "is" ARGV[ 8 : length = 3] = "Not" ARGV[ 9 : length = 4] = "Unix"
• How is the $* bash parameter interpreted, inside double quotes ?
Test script
#!/bin/bash show_args() { args "$*" } show_args UNIX "Linus Torvalds" "GNU : GNU is Not Unix"
Result
ARGC = 2 ARGV[ 1 : length = 44] = "UNIX Linus Torvalds GNU : GNU is Not Unix"
• How is the $@ bash parameter interpreted, outside double quotes ?
Test script
#!/bin/bash show_args() { args $@ } show_args UNIX "Linus Torvalds" "GNU : GNU is Not Unix"
Result
ARGC = 10 ARGV[ 1 : length = 4] = "UNIX" ARGV[ 2 : length = 5] = "Linus" ARGV[ 3 : length = 8] = "Torvalds" ARGV[ 4 : length = 3] = "GNU" ARGV[ 5 : length = 1] = ":" ARGV[ 6 : length = 3] = "GNU" ARGV[ 7 : length = 2] = "is" ARGV[ 8 : length = 3] = "Not" ARGV[ 9 : length = 4] = "Unix"
• How is the $@ bash parameter interpreted, inside double quotes ?
Test script
#!/bin/bash show_args() { args "$@" } show_args UNIX "Linus Torvalds" "GNU : GNU is Not Unix"
Result
ARGC = 4 ARGV[ 1 : length = 4] = "UNIX" ARGV[ 2 : length = 14] = "Linus Torvalds" ARGV[ 3 : length = 24] = "GNU : GNU is Not Unix"