Browse Source

Add option to chdir to a particular dir

Helpful to fight cron-related issues.
Alois Mahdal 8 years ago
parent
commit
ee923bf81c
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      dotfiles/imapdomo/utils/imapdomo

+ 7
- 1
dotfiles/imapdomo/utils/imapdomo View File

34
     local Debug     # true if debugging
34
     local Debug     # true if debugging
35
     local cmd       # imapfilter command
35
     local cmd       # imapfilter command
36
     local CfgDir    # config directory
36
     local CfgDir    # config directory
37
-    local LogDir    # config directory
37
+    local LogDir    # directory to store logs
38
+    local CdTo      # change dir to this before running imapfilter
38
     CfgDir="$HOME/.imapdomo"
39
     CfgDir="$HOME/.imapdomo"
39
     LogDir="$HOME/.cache/imapdomo/logs"
40
     LogDir="$HOME/.cache/imapdomo/logs"
40
     Debug=false
41
     Debug=false
41
     while true; do case $1 in
42
     while true; do case $1 in
43
+        -c) CdTo="$2"; shift 2 || usage ;;
42
         -d) Debug=true; SHELLFU_DEBUG=true; shift ;;
44
         -d) Debug=true; SHELLFU_DEBUG=true; shift ;;
43
         -*) usage ;;
45
         -*) usage ;;
44
         *)  break ;;
46
         *)  break ;;
48
     cmd=$(mkcmd)
50
     cmd=$(mkcmd)
49
     debug -v cmd
51
     debug -v cmd
50
     bash -n <<<"$cmd" || die
52
     bash -n <<<"$cmd" || die
53
+    if test -n "$CdTo";
54
+    then
55
+        cd "$CdTo" || die
56
+    fi
51
     eval "$cmd"
57
     eval "$cmd"
52
 }
58
 }
53
 
59