mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-04-24 07:36:53 +08:00
use local vars
This commit is contained in:
parent
f354dc5798
commit
a2b9db786b
16
install.sh
16
install.sh
|
@ -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 ----------
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user