mirror of
https://github.com/scopatz/nanorc
synced 2025-08-01 23:30:14 +02:00
Printf instead of echo
This commit is contained in:
parent
b53c091ed0
commit
94164b5e9c
82
install.sh
82
install.sh
@ -41,42 +41,43 @@ unset G_LITE G_UNSTABLE G_VERBOSE G_DIR G_THEME
|
|||||||
|
|
||||||
# Show the usage/help
|
# Show the usage/help
|
||||||
f_menu_usage(){
|
f_menu_usage(){
|
||||||
echo "Usage: $0 [ -h|-l|-u|-v|-w ] [ -d DIR ] [ -t THEME ]"
|
printf "\n Usage: %s [ -h|-l|-u|-v|-w ] [ -d DIR ] [ -t THEME ]" "$0"
|
||||||
echo
|
printf "\n"
|
||||||
echo "IMPROVED NANO SYNTAX HIGHLIGHTING FILES"
|
printf "\n IMPROVED NANO SYNTAX HIGHLIGHTING FILES"
|
||||||
echo "Get nano editor better to use and see."
|
printf "\n Get nano editor better to use and see."
|
||||||
echo
|
printf "\n"
|
||||||
echo "-h Show help or usage."
|
printf "\n -h Show help or usage."
|
||||||
echo "-l Activate lite installation."
|
printf "\n -l Activate lite installation."
|
||||||
echo " We will take account your existing .nanorc files."
|
printf "\n We will take account your existing .nanorc files."
|
||||||
echo "-u Use the unstable branch (master)."
|
printf "\n -u Use the unstable branch (master)."
|
||||||
echo "-v Show version, license and other info."
|
printf "\n -v Show version, license and other info."
|
||||||
echo "-w Turn the script more verbose, often to tests."
|
printf "\n -w Turn the script more verbose, often to tests."
|
||||||
echo
|
printf "\n"
|
||||||
echo "-d DIR"
|
printf "\n -d DIR"
|
||||||
echo " Give other directory for installation."
|
printf "\n Give other directory for installation."
|
||||||
echo " Default: ~/.nano/nanorc/"
|
printf "\n Default: ~/.nano/nanorc/"
|
||||||
echo
|
printf "\n"
|
||||||
echo "-t THEME"
|
printf "\n -t THEME"
|
||||||
echo " Give other theme for installation."
|
printf "\n Give other theme for installation."
|
||||||
echo " Default: scopatz"
|
printf "\n Default: scopatz"
|
||||||
echo " Options: nano, tpro"
|
printf "\n Options: nano, tpro"
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show version, license and other file.
|
# Show version, license and other file.
|
||||||
f_menu_version(){
|
f_menu_version(){
|
||||||
echo "IMPROVED NANO SYNTAX HIGHLIGHTING FILES"
|
printf "\n IMPROVED NANO SYNTAX HIGHLIGHTING FILES"
|
||||||
echo "Version ${G_VERSION}"
|
printf "\n Version %s" "${G_VERSION}"
|
||||||
echo
|
printf "\n"
|
||||||
echo "Copyright (C) 2014+ Anthony Scopatz et al."
|
printf "\n Copyright (C) 2014+ Anthony Scopatz et al."
|
||||||
echo "License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>."
|
printf "\n License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>."
|
||||||
echo "This is free software: you are free to change and redistribute it."
|
printf "\n This is free software: you are free to change and redistribute it."
|
||||||
echo "There is NO WARRANTY, to the extent permitted by law."
|
printf "\n There is NO WARRANTY, to the extent permitted by law."
|
||||||
echo
|
printf "\n"
|
||||||
echo "Written by Anthony Scopatz and others."
|
printf "\n Written by Anthony Scopatz and others."
|
||||||
echo
|
printf "\n"
|
||||||
echo "For bugs report, please fill an issue at https://github.com/scopatz/nanorc"
|
printf "\n For bugs report, please fill an issue at https://github.com/scopatz/nanorc"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@ -97,7 +98,7 @@ f_check_deps(){
|
|||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
for DEP in $DEPS_MISSED; do
|
for DEP in $DEPS_MISSED; do
|
||||||
echo "The '${DEP}' program is required but was not found. Install '${DEP}' first and then run this script again." >&2
|
printf "\n The '%s' program is required but was not found. Install '${DEP}' first and then run this script again." "${DEP}" >&2
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -127,7 +128,7 @@ f_set_variable(){
|
|||||||
if [ -z "${varvalue}" ]; then
|
if [ -z "${varvalue}" ]; then
|
||||||
eval "$varname=${*}"
|
eval "$varname=${*}"
|
||||||
else
|
else
|
||||||
echo "Error: ${varname} already set."
|
printf "\n Error: '%s' is already set." "${varname}"
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ _update_nanorc(){
|
|||||||
# add all includes from ~/.nano/nanorc if they're not already there
|
# add all includes from ~/.nano/nanorc if they're not already there
|
||||||
while read -r inc; do
|
while read -r inc; do
|
||||||
if ! grep -q "$inc" "${NANORC_FILE}"; then
|
if ! grep -q "$inc" "${NANORC_FILE}"; then
|
||||||
echo "$inc" >> "$NANORC_FILE"
|
printf "\n %s" "$inc" >> "$NANORC_FILE"
|
||||||
fi
|
fi
|
||||||
done < ~/.nano/nanorc
|
done < ~/.nano/nanorc
|
||||||
}
|
}
|
||||||
@ -161,14 +162,14 @@ f_install(){
|
|||||||
theme="${G_DIR}/themes/${G_THEME}/"
|
theme="${G_DIR}/themes/${G_THEME}/"
|
||||||
|
|
||||||
if cd "$HOME"; then
|
if cd "$HOME"; then
|
||||||
echo "Error: Cannot open or access ${HOME} directory."
|
printf "\n Error: Cannot open or access '%s' directory." "${HOME}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$G_DIR"
|
mkdir -p "$G_DIR"
|
||||||
|
|
||||||
if [ ! -d "$G_DIR" ]; then
|
if [ ! -d "$G_DIR" ]; then
|
||||||
echo "Error: ${G_DIR} is not a directory or cannot be accessed or created."
|
printf "\n Error: '%s' is not a directory or cannot be accessed or created." "${G_DIR}"
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -190,16 +191,13 @@ f_install(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$theme" ]; then
|
if [ ! -d "$theme" ]; then
|
||||||
echo "Error: ${G_THEME} is not a theme or cannot be accessed."
|
printf "\n Error: '%s' is not a theme or cannot be accessed." "${G_THEME}"
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch "$G_FILE"
|
touch "$G_FILE"
|
||||||
|
|
||||||
{ echo "$begin";
|
printf "\n %s \n %s \n" "$begin" "$end" >> "$G_FILE"
|
||||||
echo "";
|
|
||||||
echo "$end";
|
|
||||||
} >> $G_FILE
|
|
||||||
|
|
||||||
if [ "$G_LITE" = true ]; then
|
if [ "$G_LITE" = true ]; then
|
||||||
sed -n -i.bkp '/'"$begin"'/,/'"$end"'/ {
|
sed -n -i.bkp '/'"$begin"'/,/'"$end"'/ {
|
||||||
@ -210,7 +208,7 @@ f_install(){
|
|||||||
}
|
}
|
||||||
# r theme
|
# r theme
|
||||||
# write the includes
|
# write the includes
|
||||||
}' $G_FILE
|
}' "$G_FILE"
|
||||||
|
|
||||||
_update_nanorc_lite
|
_update_nanorc_lite
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user