mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-07-08 10:00:31 +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()
|
insert_if_not_exist()
|
||||||
{
|
{
|
||||||
filename=$1
|
local filename=$1
|
||||||
line=$2
|
local line=$2
|
||||||
fmt_note "installing \"$line\" into \"$filename\" ..."
|
fmt_note "installing \"$line\" into \"$filename\" ..."
|
||||||
mkdir -p $(dirname "$filename")
|
mkdir -p $(dirname "$filename")
|
||||||
if [ ! -f "$filename" ]; then
|
if [ ! -f "$filename" ]; then
|
||||||
@ -25,8 +25,8 @@ insert_if_not_exist()
|
|||||||
|
|
||||||
delete_if_exist()
|
delete_if_exist()
|
||||||
{
|
{
|
||||||
filename=$1
|
local filename=$1
|
||||||
line=$2
|
local line=$2
|
||||||
fmt_note "removing \"$line\" from \"$filename\" ..."
|
fmt_note "removing \"$line\" from \"$filename\" ..."
|
||||||
if [ -f "$filename" ]; then
|
if [ -f "$filename" ]; then
|
||||||
grep -vxF -- "$line" "$filename" | tee "$filename"
|
grep -vxF -- "$line" "$filename" | tee "$filename"
|
||||||
@ -35,8 +35,8 @@ delete_if_exist()
|
|||||||
|
|
||||||
create_symlink()
|
create_symlink()
|
||||||
{
|
{
|
||||||
src=$1
|
local src=$1
|
||||||
dest=$2
|
local dest=$2
|
||||||
fmt_note "creating symlink \"$dest\" --> \"$src\" ..."
|
fmt_note "creating symlink \"$dest\" --> \"$src\" ..."
|
||||||
if [ ! -f "$src" ]; then
|
if [ ! -f "$src" ]; then
|
||||||
fmt_error "\"$src\" does not exist! aborting this job ..."
|
fmt_error "\"$src\" does not exist! aborting this job ..."
|
||||||
@ -65,8 +65,8 @@ create_symlink()
|
|||||||
|
|
||||||
delete_link_if_match()
|
delete_link_if_match()
|
||||||
{
|
{
|
||||||
src=$1
|
local src=$1
|
||||||
dest=$2
|
local dest=$2
|
||||||
if [ "$(readlink $dest)" -ef "$src" ]; then
|
if [ "$(readlink $dest)" -ef "$src" ]; then
|
||||||
fmt_note "removing symlink \"$dest\" ..."
|
fmt_note "removing symlink \"$dest\" ..."
|
||||||
echo ----------
|
echo ----------
|
||||||
|
@ -118,6 +118,7 @@ post_log()
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_os_type() {
|
get_os_type() {
|
||||||
|
local ans="unknown"
|
||||||
case "$(uname -s)" in
|
case "$(uname -s)" in
|
||||||
Darwin*) ans="MacOS";;
|
Darwin*) ans="MacOS";;
|
||||||
CYGWIN*) ans="Cygwin";;
|
CYGWIN*) ans="Cygwin";;
|
||||||
@ -129,6 +130,7 @@ get_os_type() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_linux_dist() {
|
get_linux_dist() {
|
||||||
|
local ans="unknown"
|
||||||
if [ -f /etc/os-release ]; then
|
if [ -f /etc/os-release ]; then
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
ans="$ID"
|
ans="$ID"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user