That just doesn't look right. sh doesn't do string concatenation or math like that, and trying to duplicate it in my shell just gives me syntax errors. Are you sure that script is using sh? Does it have #!/bin/sh at the top or something else?
An even better approach is to start your script files with the follow-
ing three lines:
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
This approach has three advantages over the approach in the previous
paragraph. First, the location of the tclsh binary doesn't have to be
hard-wired into the script: it can be anywhere in your shell search
path. Second, it gets around the 30-character file name limit in the
previous approach. Third, this approach will work even if tclsh is
itself a shell script (this is done on some systems in order to handle
multiple architectures or operating systems: the tclsh script selects
one of several binaries to run). The three lines cause both sh and
tclsh to process the script, but the exec is only executed by sh. sh
processes the script first; it treats the second line as a comment and
executes the third line. The exec statement cause the shell to stop
processing and instead to start up tclsh to reprocess the entire
script. When tclsh starts up, it treats all three lines as comments,
since the backslash at the end of the second line causes the third line
to be treated as part of the comment on the second line.
-- excerpt from man tclsh
For example:
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
# @(#) tcl5 Demonstrate tclsh feature.
set version [ info tclversion ]
set message " Hello, world from tclsh ($version), $auto_path"
puts stdout $message
puts stdout ""
if { $argc == 0 } then {
puts stdout " No parameters provided."
} else {
set i 0
foreach arg $argv {
set m1 " $i $arg"
incr i
set m2 ""
if { [ file exists $arg ] } then {
set m2 [ join [ list "(" [ file type $arg ] ")" ] ]
}
puts stdout "$m1 $m2"
}
}
exit 0
producing:
% ./tcl5
Hello, world from tclsh (8.4),...
No parameters provided.
and:
% ./tcl5 a x=1 3.14
Hello, world from tclsh (8.4), ...
0 a
1 x=1
2 3.14
The "1+ .." part might be taken from perl:
#!/bin/sh -- # -*- perl -*- -p
eval 'exec perl -wS $0 ${1+"$@"}'
if $running_under_some_shell;
-- excerpt from man perlrun
You might be able to fiddle with single quotes, specific shells, etc., to make the command in the OP work . Best wishes ... cheers, drl