Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Ask user before rm -rf'ing in ramdisk create bash script #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ask user before rm -rf'ing in ramdisk create bash script #57

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 25, 2018

Description

  • Ask user before rm -rf'ing in ramdisk create bash script
  • This also changes from ../name to ./name, partially for a bit more safety. Feel free to cherrypick/revert though.

Motivation and Context

  • It was a TODO item

How Has This Been Tested?

Tried running it myself

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • Where appropriate examples are updated such as config.ini.example
  • I have updated the documentation accordingly.

This also changes from `../name` to `./name`, partially for a bit more safety. Feel free to cherrypick/revert though.
Copy link
Contributor

@krzee krzee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice. i like that you remembered -r for read :)
could you either wrap it in something like until [[ $REPLY =~ ^[Yy]$ ]] ;do
or just add an else echo "you answered no, not making the ramdisk. run again if you want to make the ramdisk" && exit 1 or whatever...

Basically only trying to get around users saying "I ran the script, got no errors/output, and have no ramdisk"

It should also exit non 0 if not making the ramdisk just in case :)

@krzee
Copy link
Contributor

krzee commented Oct 25, 2018

also i think if you're going to change the path to make the script not work from the place where it sits by default, then a major note belongs being sent to the user about it. really i dont think the path should be changed to break it and require the user to move it manually (which will later have to be moved back or break git pull).

@ghost
Copy link
Author

ghost commented Oct 26, 2018

Thanks @krzee! Changed back to ../ instead of ./, checks for the return status of mount, exits 1 for any other condition than 'created ramdisk' as far as I can tell

The downside is that the rm/mkdir might fail because it's already mounted or device is busy when it's trying to rm, but if it exists already then the mount command will return 0, so no real harm there.

@krzee
Copy link
Contributor

krzee commented Oct 28, 2018

Sorry it took me so long to respond, i have been entertaining visitors from outside the country.
The changes look good!
The only thing I could suggest would be to make a variable for the dir to mount on. So maybe something like dir="../temp_mad" at the top and then use "$dir" in the rest of the code. That would make it easier for people to change it to your ./temp_mad or whatever other dir they might want it in.
I don't see that as a big deal really, i think this PR is ready either way. Thank you! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants