Thanks again for your help!
]]>[...] But the OSS script uses the double quotes in case the parameters on the command-line were given in error.
Quotes are always a good idea. If you don't use quotes in the case statement, someone could easily break your script by quoting command line parameters. For example with `script "one two" three` the first parameter actually contains the "one two", The case statement would expand that to `case one two in` and there would be an error. But if you quote the $1 then it would expand to `case "one two" in` and it would work as intended.
Incorrect. The argument of a case statement is not subject to any form of expansion that might break this. You never need to quote it unless it's a string literal or you intentionally pass something which contains space.
There's no glob expansion or syntax error here...
v='foo bar*'
case $v in
...
esac
#!/bin/sh
suspend_osssound()
{
/usr/lib/oss/scripts/killprocs.sh
/usr/sbin/soundoff
}
resume_osssound()
{
/usr/sbin/soundon
}
case "$1" in
pre)
suspend_osssound
;;
post)
resume_osssound
;;
*) exit $NA
;;
esac
It is the same as the one in the OSS wiki entry, but slightly configured to work under logind and not pm-utils. Of course the new location is /usr/lib/systemd/system-sleep/.
I'm about to update the wiki with my code, so I'd like to know if there aren't any major mistakes. I tested it and it works but I want to get sure
PS: Do people actually still use pm-utils for suspending or can I safely remove the previous script from the wiki?
EDIT: Added double quotes
]]>#!/bin/sh
case $1/$2 in
pre/*)
echo "Going to $2..."
;;
post/*)
echo "Waking up from $2..."
;;
esac
Now what do I need the /*) for in the cases pre and post? What does it do? And why isn't there any *) in the end which would exit the script if none of the above is true?
Secondly, why does it say case $1/$2 in, but not case $1 in, what is the $2 needed for? E.g. in this script only $1 is used: https://wiki.archlinux.org/index.php/OS … ibernation
And third question is, if I do really need the double quotes around $1? Does it make any difference?
Sorry for my incompetence but I'm not a dev and as I already said I've never did any bash scripting...
Thanks in advance
best regards
nuc