Flash Notes

Commandes - Interpréteur de commandes


• Comment est interprété le paramètre $* de bash, hors des doubles quotes ?

Script de test

#!/bin/bash

show_args()
{
	args $*
}

show_args UNIX "Linus Torvalds" "GNU    : GNU is Not Unix"

Résultat

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"

• Comment est interprété le paramètre $* de bash, à l'intérieur des doubles quotes ?

Script de test

#!/bin/bash

show_args()
{
	args "$*"
}

show_args UNIX "Linus Torvalds" "GNU    : GNU is Not Unix"

Résultat

ARGC = 2

ARGV[  1 : length =  44] = "UNIX Linus Torvalds GNU    : GNU is Not Unix"

• Comment est interprété le paramètre $@ de bash, hors des doubles quotes ?

Script de test

#!/bin/bash

show_args()
{
	args $@
}

show_args UNIX "Linus Torvalds" "GNU    : GNU is Not Unix"

Résultat

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"

• Comment est interprété le paramètre $@ de bash, à l'intérieur des doubles quotes ?

Script de test

#!/bin/bash

show_args()
{
	args "$@"
}

show_args UNIX "Linus Torvalds" "GNU    : GNU is Not Unix"

Résultat

ARGC = 4
 
ARGV[  1 : length =   4] = "UNIX"
ARGV[  2 : length =  14] = "Linus Torvalds"
ARGV[  3 : length =  24] = "GNU    : GNU is Not Unix"