use local vars

This commit is contained in:
Dict Xiong 2022-10-29 02:14:39 +08:00
parent f354dc5798
commit a2b9db786b
2 changed files with 10 additions and 8 deletions

View File

@ -13,8 +13,8 @@ crontab_job="0 * * * * ${DOTFILES}/update.sh"
insert_if_not_exist()
{
filename=$1
line=$2
local filename=$1
local line=$2
fmt_note "installing \"$line\" into \"$filename\" ..."
mkdir -p $(dirname "$filename")
if [ ! -f "$filename" ]; then
@ -25,8 +25,8 @@ insert_if_not_exist()
delete_if_exist()
{
filename=$1
line=$2
local filename=$1
local line=$2
fmt_note "removing \"$line\" from \"$filename\" ..."
if [ -f "$filename" ]; then
grep -vxF -- "$line" "$filename" | tee "$filename"
@ -35,8 +35,8 @@ delete_if_exist()
create_symlink()
{
src=$1
dest=$2
local src=$1
local dest=$2
fmt_note "creating symlink \"$dest\" --> \"$src\" ..."
if [ ! -f "$src" ]; then
fmt_error "\"$src\" does not exist! aborting this job ..."
@ -65,8 +65,8 @@ create_symlink()
delete_link_if_match()
{
src=$1
dest=$2
local src=$1
local dest=$2
if [ "$(readlink $dest)" -ef "$src" ]; then
fmt_note "removing symlink \"$dest\" ..."
echo ----------

View File

@ -118,6 +118,7 @@ post_log()
}
get_os_type() {
local ans="unknown"
case "$(uname -s)" in
Darwin*) ans="MacOS";;
CYGWIN*) ans="Cygwin";;
@ -129,6 +130,7 @@ get_os_type() {
}
get_linux_dist() {
local ans="unknown"
if [ -f /etc/os-release ]; then
. /etc/os-release
ans="$ID"