Posted to tcl by berndj at Thu Jul 04 15:42:19 GMT 2019view pretty
#!/usr/bin/tclsh proc libfunc_args { filename } { set r { } foreach i [split $filename "/"] { lappend r $i } return $r } proc vectors { dummy tool_options } { set input_file "/etc/hosts" set command { } foreach opt $tool_options { set x [expr "\"$opt\""] lappend command $x puts "opt: $opt -> $x" } return $command } set cmd [vectors "dummy" { "hello" "world" "a sentence" "[libfunc_args \$input_file]" }] foreach c $cmd { puts "command item: $c" } Actual output: opt: hello -> hello opt: world -> world opt: a sentence -> a sentence opt: [libfunc_args $input_file] -> {} etc hosts command item: hello command item: world command item: a sentence command item: {} etc hosts Desired output: opt: hello -> hello opt: world -> world opt: a sentence -> a sentence opt: [libfunc_args $input_file] -> {} etc hosts command item: hello command item: world command item: a sentence command item: {} command item: etc command item: hosts