Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe rm -rf example in documentation #473

Closed
osg opened this Issue Jan 26, 2015 · 9 comments

Comments

Projects
None yet
3 participants
@osg
Copy link

osg commented Jan 26, 2015

At http://prometheus.github.io/docs/operating/storage/, the rm -rf $STORAGE_PATH/* example is unsafe.

Alternative:
rm -r ${STORAGE_PATH}

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jan 26, 2015

I was thinking about this when writing it, but the problem is that we don't want to remove the directory itself, just its contents. Hmm...

@osg

This comment has been minimized.

Copy link
Author

osg commented Jan 26, 2015

What happens when you test this on someone else's box:
cd <storage-path>
rm -r *

@grobie

This comment has been minimized.

Copy link
Member

grobie commented Jan 27, 2015

As this is just an example, there is no need to use an environment variable. The fact that storage path is supposed to be replaced by the actual content can be shown in a safer way as well, although not as elegant as with a bash variable. For example:

rm -rf /path/to/storage/*
@osg

This comment has been minimized.

Copy link
Author

osg commented Jan 27, 2015

Note: The syntax within carrots (<>) is consistent with replaceable syntax on page http://prometheus.github.io/docs/concepts/data_model/#notation. That said, is the most consistent because it does not contain a hyphen.

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jan 27, 2015

How about rm -rf <storage path>/*, because it's a single line and doesn't destroy anything, in contrast to the other suggestion where rm -r * will still destroy your current working directory if you accidentally execute it after the first one fails.

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jan 27, 2015

(and most importantly, if someone just copies the line without replacing anything, it will result in a syntax error)

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jan 27, 2015

Done.

@osg

This comment has been minimized.

Copy link
Author

osg commented Jan 27, 2015

+1

@juliusv juliusv closed this Jan 27, 2015

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.