/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to dev/dev

  • Committer: Tim Marston
  • Date: 2016-12-13 21:40:34 UTC
  • Revision ID: tim@ed.am-20161213214034-nd5t7ztnlrjd627i
fix add command and generic filename expansion/resolution to expend to
homedir-relative filename and absolute filename based on original filename, as
specified, rather than a fully, symlink-resolved filename.  So, e.g., if ~/bob
was a symlink to ~/fred, then ~/bob/a would resolve to the relative filename
bob/a, becuase it is inside the homedir (it would resolve to fred/a otherwise)

Show diffs side-by-side

added added

removed removed

5
5
        mkdir ~/.stdhome
6
6
fi
7
7
if [ ! -d ~/.stdhome ]; then
8
 
        echo "Can't determine current state: no ~/.stdhome"
 
8
        echo "ERROR: can't determine current state: no ~/.stdhome"
9
9
        exit 1
10
10
fi
11
11
 
17
17
        CURRENT=off
18
18
fi
19
19
if [ -z "$CURRENT" ]; then
20
 
        echo "Can't determine current state" >&2
 
20
        echo "ERROR: can't determine current state" >&2
21
21
        exit 1
22
22
fi
23
23
 
40
40
 
41
41
        # create/check rc
42
42
        if [ ! -f ~/.stdhomerc ]; then
43
 
                echo "No ~/.stdhomerc, creating..."
 
43
                echo "ERROR: no ~/.stdhomerc, creating..."
44
44
                echo "[stdhome]" >> ~/.stdhomerc
45
45
                echo "#home-dir = ~/tmp/stdhome-dev" >> ~/.stdhomerc
46
46
                mkdir -p ~/tmp/stdhome-dev
47
47
        fi
48
 
        if ! grep -q '^#home-dir ?= ?~/tmp/stdhome-dev' ~/.stdhomerc; then
49
 
                echo "No commented home-dir in ~/.stdhomerc"
 
48
        if ! grep -q '^#home-dir \?= \?~/tmp/stdhome-dev' ~/.stdhomerc; then
 
49
                echo "ERROR: no commented home-dir in ~/.stdhomerc"
50
50
                echo "Please add the following to the [stdhome] section:"
51
51
                echo "#home-dir = ~/tmp/stdhome-dev"
52
52
                exit 1
62
62
        fi
63
63
        sed -ie 's/^#\(home-dir\)/\1/' ~/.stdhomerc
64
64
        mkdir -p ~/tmp/stdhome-dev
 
65
        DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
 
66
        ln -s "$DIR"/src/stdhome ~/bin/stdhome
65
67
 
66
68
elif [ "$TARGET" == "off" ]; then
67
69
 
73
75
        echo turning off
74
76
 
75
77
        # check rc
76
 
        if ! grep -q '^home-dir ?= ?~/tmp/stdhome-dev' ~/.stdhomerc; then
77
 
                echo "No uncommented home-dir in ~/.stdhomerc"
 
78
        if ! grep -q '^home-dir \?= \?~/tmp/stdhome-dev' ~/.stdhomerc; then
 
79
                echo "ERROR: no uncommented home-dir in ~/.stdhomerc"
78
80
                exit 1
79
81
        fi
80
82
 
82
84
        mv ~/.stdhome{,.dev}
83
85
        mv ~/.stdhome{.orig,}
84
86
        sed -ie 's/^home-dir/#\0/' ~/.stdhomerc
 
87
        rm -f ~/bin/stdhome
85
88
 
86
89
else
87
90
        echo currently $CURRENT