deducing the name of the variable from positional parameters in a posix shell -


#!/bin/sh foo() {   printf "$1" } random_var="hello\n" foo $random_var 

when pass 1 or more variables function, in case foo, accessible through $1 $2 , on; how go step inside foo , print name of original variable in case means random_var ?

succinctly, don't or can't tell inside function variables used create argument function. there's no guarantee argument variable, or single variable — example:

foo 123 foo ${home}:${path} 

further, if function cares, mis-written. should self-contained possible, , therefore independent of such issues. if isn't, suggests maybe function not functionally cohesive.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -