-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
simplify install #1830
simplify install #1830
Conversation
This helps us make the logic easier to read, and remove unneeded confusion.
This will ensure users will specify whether they want to overwrite the backup or not, and check it even when we do silent installation This does change the default behaviour and exits if the -f flag is not specified and a backup is present.
3d7c279
to
af17501
Compare
This fix looks like it should fix the issue |
install.sh
Outdated
@@ -76,6 +77,69 @@ function backup_append() { | |||
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" | |||
} | |||
|
|||
function check_for_backup() { | |||
if ! [ -e "$HOME/$BACKUP_FILE" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double bracket test are technically safer. if we're writing or transposing new things, I'd like to push to switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
install.sh
Outdated
@@ -76,6 +77,69 @@ function backup_append() { | |||
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" | |||
} | |||
|
|||
function check_for_backup() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to road block since this in the install script, but it'd be nice to start making all functions be prefixed with _bash-it
or something consistent and namespaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this prefix to all functions in install.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NoahGorny This is the first time I've really looked at this file in detail. I can see some places we'll want to improve in the future, but this is a great fix + cleanup. Thanks for this!
Description
Cleans up the config backup logic and split it into smaller functions.
Also add a new flag which allows us to overwrite backups silently (previously we did not check for existing backups in silent installations). This does change the default behaviour, so I am open to a debate on that.
Motivation and Context
#1829 prompted me to take a look- and I indeed saw a problem. I refactored the code a bit in order to fix this.
Closes #1829
How Has This Been Tested?
Locally, tested various flags and combinations, with and without backup. Works as expected.
As I said, now silent installations fail if a backup is already present, unless "-f/--overwrite-backup" is specified
Types of changes
Checklist:
clean_files.txt
and formatted it usinglint_clean_files.sh
.