git-commit: add an error check for mkdir
authorDenis Ovsienko <denis@ovsienko.info>
Tue, 8 Jan 2019 21:40:27 +0000 (21:40 +0000)
committerDenis Ovsienko <denis@ovsienko.info>
Tue, 8 Jan 2019 21:41:10 +0000 (21:41 +0000)
[skip ci]

gateways/git-commit

index efb8a4c..e341168 100755 (executable)
@@ -97,7 +97,12 @@ git_commit_or_exit()
        # git processes the path to the file automatically, but the shell
        # redirection obviously does not.
        DIRNAME=`dirname "$FILEPATH"`
-       [ -d "$DIRNAME" ] || mkdir -p "$DIRNAME"
+       if [ ! -d "$DIRNAME" ]; then
+               mkdir -p "$DIRNAME" || {
+                       echo "$THISFILE: failed to create missing directory '$DIRNAME'" >&2
+                       exit 11
+               }
+       fi
 
        # New file contents is on stdin.
        cat > "$FILEPATH" || {