Re: what does the $ as a variable do?

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: coverturtle
Date:  
To: Main PLUG discussion list
Subject: Re: what does the $ as a variable do?
On 01/18/2015 07:49 PM, Michael Havens wrote:
> people are reporting a bug in steam. apparently there is a line in it
> that is deleting all the personal dataall connected read/write media.
> this is how the line reads:
>
>
> rm -rf $STEAMROOT/*
>
>
> what does the '$' expand too?
>
> :-)~MIKE~(-:
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss

DON'T EXECUTE THE ABOVE LINE!
I'm assuming you have a terminal to verify this:
If the variable "STEAMROOT" is empty, it expands to the null string,
i.e. empty string.
i.e. /* which is very bad if preceded by rm -rf because "r" is
recursive and "f" means
to force the execution of the remove and it will remove all your files.
If it is <someString> then it expands to <someString>/*
it is supposed to expand to the path for the home directory for the
steam data
but if empty, wipes out any part of file system in which the bash script is
executing and for which bash has permissions.
$STEAMROOT should be set to some harmless default value like /tmp
If the bash line is set to
rm -rf ${STEAMROOT:-/tmp}/*
then there shouldn't be any unwanted damage. Check out
man rm
and
man bash
for more than you wanted to know. Search ("/") for "${" in man bash for
details.
Jon

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss