From 78aacafad4880b981315ea901ffca039b640c346 Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Tue, 19 Dec 2017 22:57:57 -0800 Subject: [PATCH] Multiple fixes: pathname handling handle spaces handle multiple arguments if the last argument ends with a "/" completely untested --- bin/advance | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/advance b/bin/advance index a72ac10..1a364f6 100644 --- a/bin/advance +++ b/bin/advance @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # # Simple script for the terminal that mimics the operation of AdvancedNewFile (Vim plugin) @@ -7,9 +7,16 @@ # License: MIT # -if [[ "$@" == */ ]]; then - mkdir -p $@ -else - for f in "$@"; do mkdir -p "$(dirname "$f")"; done - touch "$@" -fi + +for f in "$@" +do + dir="${f%/*}" + file="${f##*/}" + + if [ -n "$dir" ]; then + mkdir -p "$dir" + fi + if [ -n "$file" ]; then + touch "./$dir/$file" + fi +done -- 2.54.0