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,11 +34,13 @@ main() {
34 34
     local Debug     # true if debugging
35 35
     local cmd       # imapfilter command
36 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 39
     CfgDir="$HOME/.imapdomo"
39 40
     LogDir="$HOME/.cache/imapdomo/logs"
40 41
     Debug=false
41 42
     while true; do case $1 in
43
+        -c) CdTo="$2"; shift 2 || usage ;;
42 44
         -d) Debug=true; SHELLFU_DEBUG=true; shift ;;
43 45
         -*) usage ;;
44 46
         *)  break ;;
@@ -48,6 +50,10 @@ main() {
48 50
     cmd=$(mkcmd)
49 51
     debug -v cmd
50 52
     bash -n <<<"$cmd" || die
53
+    if test -n "$CdTo";
54
+    then
55
+        cd "$CdTo" || die
56
+    fi
51 57
     eval "$cmd"
52 58
 }
53 59