瀏覽代碼

Apply ShellCheck advice

Alois Mahdal 9 年之前
父節點
當前提交
b0104f19fe

+ 1
- 1
dotfiles.config/Xlib/bin/setup 查看文件

@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-host=`hostname -s`
3
+host=$(hostname -s)
4 4
 
5 5
 cat<<EOF > $HOME/.Xdefaults
6 6
 !! This file is generated by .config/Xlib/bin/setup

+ 12
- 12
dotfiles.config/Xlib/colorscheme/mkdemo 查看文件

@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-. $(ffoom path) || exit 3
3
+. "$(ffoom path)" || exit 3
4 4
 
5 5
 ffoo import pretty
6 6
 
@@ -18,8 +18,8 @@ xd2html() {
18 18
         test -n "$name"  || continue
19 19
         test -n "$color" || continue
20 20
         debug -v name color
21
-        test "$name" == "URxvt.background" && echo "$color" > $CSDEMO_BG
22
-        test "$name" == "URxvt.foreground" && echo "$color" > $CSDEMO_FG
21
+        test "$name" == "URxvt.background" && echo "$color" > "$CSDEMO_BG"
22
+        test "$name" == "URxvt.foreground" && echo "$color" > "$CSDEMO_FG"
23 23
         echos "        <p style='color: $color'>$name</p>"
24 24
     done
25 25
 }
@@ -43,20 +43,20 @@ css() {
43 43
     echos "body {"
44 44
     echos "    font-size: xx-large;"
45 45
     echos "    font-family: monospace;"
46
-    echos "    color: $(cat $CSDEMO_FG);"
47
-    echos "    background-color: $(cat $CSDEMO_BG);"
46
+    echos "    color: $(cat "$CSDEMO_FG");"
47
+    echos "    background-color: $(cat "$CSDEMO_BG");"
48 48
     echos "}"
49 49
 }
50 50
 
51 51
 test -n "$CSDEMO_FNAME" || usage_is "scheme.Xresources"
52 52
 
53
-htmlhead                    >  $CSDEMO_FNAME.html
54
-cat $CSDEMO_FNAME | xd2html >> $CSDEMO_FNAME.html
55
-htmltail                    >> $CSDEMO_FNAME.html
56
-debug -f $CSDEMO_FG $CSDEMO_BG
53
+htmlhead                 >  "$CSDEMO_FNAME.html"
54
+<"$CSDEMO_FNAME" xd2html >> "$CSDEMO_FNAME.html"
55
+htmltail                 >> "$CSDEMO_FNAME.html"
56
+debug -f "$CSDEMO_FG" "$CSDEMO_BG"
57 57
 test -s "$CSDEMO_FG" || die "failed to parse URxvt.foreground"
58 58
 test -s "$CSDEMO_BG" || die "failed to parse URxvt.background"
59
-css                         >  $CSDEMO_FNAME.css
59
+css                         >  "$CSDEMO_FNAME.css"
60 60
 
61
-rm $CSDEMO_BG
62
-rm $CSDEMO_FG
61
+rm "$CSDEMO_BG"
62
+rm "$CSDEMO_FG"

+ 2
- 2
dotfiles/bash/setup 查看文件

@@ -1,11 +1,11 @@
1 1
 #!/bin/bash
2 2
 
3 3
 put() {
4
-    echo "$1" >> $HOME/.bashrc
4
+    echo "$1" >> "$HOME/.bashrc"
5 5
 }
6 6
 
7 7
 mark="# added by https://github.com/AloisMahdal/mydots"
8
-if grep -qF "$mark" $HOME/.bashrc;
8
+if grep -qF "$mark" "$HOME/.bashrc";
9 9
 then
10 10
     echo "already set up, giving up";
11 11
     exit 1;

+ 3
- 3
dotfiles/gittum/bin/findcat 查看文件

@@ -1,6 +1,6 @@
1 1
 #!/bin/sh
2 2
 
3 3
 NAME=$1
4
-cat .git_$NAME 2>/dev/null \
5
-    || cat .git/gittum/$NAME 2>/dev/null \
6
-    || cat ~/.gittum/default/$NAME 2>/dev/null
4
+cat ".git_$NAME" 2>/dev/null \
5
+    || cat ".git/gittum/$NAME" 2>/dev/null \
6
+    || cat "$HOME/.gittum/default/$NAME" 2>/dev/null

+ 16
- 15
dotfiles/gittum/bin/setup 查看文件

@@ -1,23 +1,24 @@
1 1
 #!/bin/bash
2 2
 
3
-git_binary=`which git`
4
-
5
-if [[ -x $HOME/bin/git ]]; then
6
-    git_binary=$HOME/bin/git
7
-fi
8
-
9
-gitver=`$git_binary --version | cut -d ' ' -f 3`
10
-if [[ "$gitver" > "1.8" ]]; then
3
+git_binary=$(which git)
4
+if [[ -x "$HOME/bin/git" ]]; then
5
+    git_binary="$HOME/bin/git"
6
+gitver=$(git --version | cut -d ' ' -f 3)
7
+if [[ "x$gitver" > "x1.8" ]]; then
11 8
     tilde='~'
12 9
 else
13 10
     tilde=$HOME
14 11
 fi
15 12
 
16
-host=`hostname -s`
17
-user=`whoami`
13
+host=$(hostname -s)
14
+user=$(whoami)
15
+
16
+mkconfig() {
17
+    echo "[include]"
18
+    echo "    path = $tilde/.gittum/main.gitconfig"
19
+    echo "    path = $tilde/.gittum/host/$host.gitconfig"
20
+    echo "    path = $tilde/.gittum/user/$user.gitconfig"
21
+    echo "    path = $tilde/.gittum/private.gitconfig"
22
+}
18 23
 
19
-printf "[include]\n" >> ~/.gitconfig
20
-printf "    path = $tilde/.gittum/main.gitconfig\n" >> ~/.gitconfig
21
-printf "    path = $tilde/.gittum/host/$host.gitconfig\n" >> ~/.gitconfig
22
-printf "    path = $tilde/.gittum/user/$user.gitconfig\n" >> ~/.gitconfig
23
-printf "    path = $tilde/.gittum/private.gitconfig\n" >> ~/.gitconfig
24
+mkconfig >>"$HOME/.gitconfig"

+ 3
- 4
dotfiles/gittum/bin/sibling 查看文件

@@ -32,7 +32,7 @@ die() {
32 32
 }
33 33
 
34 34
 usage() {
35
-    echo "usage: git $(basename $0) [-v] [-s SIBLING] [-r REMOTE] PROJECT"
35
+    echo "usage: git $(basename "$0") [-v] [-s SIBLING] [-r REMOTE] PROJECT"
36 36
     exit 0
37 37
 }
38 38
 
@@ -55,7 +55,6 @@ think() {
55 55
 ## initz
56 56
 #
57 57
 
58
-origin_name="origin"
59 58
 sibling_conf=".gittum-sibling"
60 59
 verbose=false
61 60
 sibling=$(find -maxdepth 1 -type d -name "[^.]*" | sort | head -1)
@@ -80,10 +79,10 @@ test -d "$sibling" || die "sibling does not exist: $sibling"
80 79
 #
81 80
 
82 81
 pushd "$sibling" >/dev/null
83
-new_remote=$(rewrite_uri $remote_name $project)
82
+new_remote=$(rewrite_uri "$remote_name" "$project")
84 83
 popd >/dev/null
85 84
 
86 85
 test -n "$new_remote" || die "no such remote at sibling: $new_remote at $sibling"
87 86
 
88 87
 think \'git clone $new_remote\'
89
-git clone $new_remote
88
+git clone "$new_remote"