1
0
Fork 0
mirror of https://github.com/arkenfox/user.js.git synced 2025-05-15 21:27:11 +02:00

Making the silent flag suppress output

This commit is contained in:
Johan Sjöblom 2022-03-22 22:23:25 +01:00
parent b4225baaf2
commit c65b92407d
2 changed files with 33 additions and 18 deletions

17
prefsCleaner.sh Normal file → Executable file
View file

@ -20,7 +20,7 @@ cd "$(dirname "${sfp}")"
fQuit() { fQuit() {
## change directory back to the original working directory ## change directory back to the original working directory
cd "${currdir}" cd "${currdir}"
[ "$1" -eq 0 ] && echo -e "\n$2" || echo -e "\n$2" >&2 [ "$1" -ne 0 ] && echo -e "\n$2" >&2
exit $1 exit $1
} }
@ -71,12 +71,21 @@ fStart() {
fFF_check fFF_check
bakfile="prefs.js.backup.$(date +"%Y-%m-%d_%H%M")" bakfile="prefs.js.backup.$(date +"%Y-%m-%d_%H%M")"
mv prefs.js "${bakfile}" || fQuit 1 "Operation aborted.\nReason: Could not create backup file $bakfile" mv prefs.js "${bakfile}" || fQuit 1 "Operation aborted.\nReason: Could not create backup file $bakfile"
if [ "$1" -eq 1 ]; then
echo -e "\nprefs.js backed up: $bakfile" echo -e "\nprefs.js backed up: $bakfile"
echo "Cleaning prefs.js..." echo "Cleaning prefs.js..."
fi
fClean "$bakfile" fClean "$bakfile"
fQuit 0 "All done!"
if [ "$1" -eq 1 ]; then
echo -e "\nAll done!"
fi
fQuit 0
} }
[ "$1" == '-s' ] && fStart 0
echo -e "\n\n" echo -e "\n\n"
echo " ╔══════════════════════════╗" echo " ╔══════════════════════════╗"
echo " ║ prefs.js cleaner ║" echo " ║ prefs.js cleaner ║"
@ -88,12 +97,10 @@ echo "It will remove any entries from prefs.js that also exist in user.js."
echo "This will allow inactive preferences to be reset to their default values." echo "This will allow inactive preferences to be reset to their default values."
echo -e "\nThis Firefox profile shouldn't be in use during the process.\n" echo -e "\nThis Firefox profile shouldn't be in use during the process.\n"
[ "$1" == '-s' ] && fStart
select option in Start Help Exit; do select option in Start Help Exit; do
case $option in case $option in
Start) Start)
fStart fStart 1
;; ;;
Help) Help)
fUsage fUsage

View file

@ -52,6 +52,7 @@ fi
show_banner() { show_banner() {
if [ "$CONFIRM" = 'yes' ]; then
echo -e "${BBLUE} echo -e "${BBLUE}
############################################################################ ############################################################################
#### #### #### ####
@ -63,6 +64,7 @@ show_banner() {
############################################################################" ############################################################################"
echo -e "${NC}\n" echo -e "${NC}\n"
echo -e "Documentation for this script is available here: ${CYAN}https://github.com/arkenfox/user.js/wiki/5.1-Updater-[Options]#-maclinux${NC}\n" echo -e "Documentation for this script is available here: ${CYAN}https://github.com/arkenfox/user.js/wiki/5.1-Updater-[Options]#-maclinux${NC}\n"
fi
} }
######################### #########################
@ -220,7 +222,9 @@ add_override() {
if [ -f "$input" ]; then if [ -f "$input" ]; then
echo "" >> user.js echo "" >> user.js
cat "$input" >> user.js cat "$input" >> user.js
if [ "$CONFIRM" = 'yes' ]; then
echo -e "Status: ${GREEN}Override file appended:${NC} ${input}" echo -e "Status: ${GREEN}Override file appended:${NC} ${input}"
fi
elif [ -d "$input" ]; then elif [ -d "$input" ]; then
SAVEIFS=$IFS SAVEIFS=$IFS
IFS=$'\n\b' # Set IFS IFS=$'\n\b' # Set IFS
@ -244,12 +248,12 @@ update_userjs() {
declare -r newfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')" declare -r newfile="$(download_file 'https://raw.githubusercontent.com/arkenfox/user.js/master/user.js')"
[ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed [ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed
if [ "$CONFIRM" = 'yes' ]; then
echo -e "Please observe the following information: echo -e "Please observe the following information:
Firefox profile: ${ORANGE}$(pwd)${NC} Firefox profile: ${ORANGE}$(pwd)${NC}
Available online: ${ORANGE}$(get_userjs_version "$newfile")${NC} Available online: ${ORANGE}$(get_userjs_version "$newfile")${NC}
Currently using: ${ORANGE}$(get_userjs_version user.js)${NC}\n\n" Currently using: ${ORANGE}$(get_userjs_version user.js)${NC}\n\n"
if [ "$CONFIRM" = 'yes' ]; then
echo -e "This script will update to the latest user.js file and append any custom configurations from user-overrides.js. ${RED}Continue Y/N? ${NC}" echo -e "This script will update to the latest user.js file and append any custom configurations from user-overrides.js. ${RED}Continue Y/N? ${NC}"
read -p "" -n 1 -r read -p "" -n 1 -r
echo -e "\n" echo -e "\n"
@ -273,12 +277,16 @@ update_userjs() {
cp user.js "$bakname" &>/dev/null cp user.js "$bakname" &>/dev/null
mv "${newfile}" user.js mv "${newfile}" user.js
if [ "$CONFIRM" = 'yes' ]; then
echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}" echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}"
fi
if [ "$ESR" = true ]; then if [ "$ESR" = true ]; then
sed -e 's/\/\* \(ESR[0-9]\{2,\}\.x still uses all.*\)/\/\/ \1/' user.js > user.js.tmp && mv user.js.tmp user.js sed -e 's/\/\* \(ESR[0-9]\{2,\}\.x still uses all.*\)/\/\/ \1/' user.js > user.js.tmp && mv user.js.tmp user.js
if [ "$CONFIRM" = 'yes' ]; then
echo -e "Status: ${GREEN}ESR related preferences have been activated!${NC}" echo -e "Status: ${GREEN}ESR related preferences have been activated!${NC}"
fi fi
fi
# apply overrides # apply overrides
if [ "$SKIPOVERRIDE" = false ]; then if [ "$SKIPOVERRIDE" = false ]; then