diff --git a/scripts/Dmerge b/scripts/Dmerge index 2dbf2f1..767c5b2 100755 --- a/scripts/Dmerge +++ b/scripts/Dmerge @@ -80,6 +80,16 @@ if(~ $mode file) { exit 1 } + # Verify file extensions + if(! ~ $srcpath *.md *.org *.txt) { + echo 'error: source must be .md, .org, or .txt file' >[1=2] + exit 1 + } + if(! ~ $dstpath *.md *.org *.txt) { + echo 'error: destination must be .md, .org, or .txt file' >[1=2] + exit 1 + } + # Extract content without frontmatter (everything after first blank line) awk ' BEGIN { found_blank = 0 } @@ -103,7 +113,7 @@ if(~ $mode file) { rm /tmp/content.$pid # Update all backlinks pointing to source - 9p read denote/n/$src/backlinks | awk -F'|' '{print $1}' | while(read linkid) { + for(linkid in `{9p read denote/n/$src/backlinks | awk -F'|' '{print $1}'}) { linkid=`{echo $linkid | awk '{gsub(/^ +| +$/, ""); print}'} if(! ~ $#linkid 0) { linkpath=`{9p read denote/n/$linkid/path} @@ -137,6 +147,12 @@ if not if(~ $mode region) { exit 1 } + # Verify file extension + if(! ~ $dstpath *.md *.org *.txt) { + echo 'error: destination must be .md, .org, or .txt file' >[1=2] + exit 1 + } + # Apply formatting to selection switch($format) { case plain