* Alexander Huemer <alexander.huemer@xxxxx> [2013-10-16 14:26]: > Hi, > > I wrote a shell script on a non-Debian system and assumed, in my > greenness, that testing it with #!/bin/bash --posix would ensure that > the script would run under dash too. I was wrong. Of course that is the > fault of bash and not dash. > Here is a simplified form of the script: > > #!/bin/dash > # This works when run with #!/bin/bash --posix > > func() { > cat /proc/1/environ > } > > sudo sh -c "$(declare -f func); func" > > Can I do anything equivalent with dash? No. > I did not find anything in the docs, but hope dies last. This is even ugly in bash because you're abusing a function as a variable. And the shell you get with "sudo sh" depends on your system configuration. You can embed commands using a here-doc instead of func()... sudo /bin/dash << "EOF" cat /proc/1/environ # ... EOF > Of course I can swap the function out in a seperate script, but I'd like > to avoid that. ...but this seems to be the right thing to do rather than embedding a script inside a script. -- Guido Berhoerster -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html