From: Colin Patrick McCabe Date: Mon, 24 May 2010 23:04:07 +0000 (-0700) Subject: Add vimstart X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=435e4038e090576c3b9d0d8b43fd56546653d717;p=cmccabe-bin Add vimstart --- diff --git a/Makefile b/Makefile index 27e3efd..22ef97c 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,7 @@ errno_speak: errno_speak.o simple_time: simple_time.o +vimstart: vimstart.o + clean: rm -rf errno_speak simple_time *.o diff --git a/vimstart.c b/vimstart.c new file mode 100644 index 0000000..a72e878 --- /dev/null +++ b/vimstart.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char **argv) +{ + close(0); /* close stdin */ + + /* duplicate stdin from stderr */ + if (dup(2) < 0) { + perror("dup failed:"); + return 1; + } + execvp("/usr/bin/vim", argv); + perror("could not execute program"); + return 1; +} diff --git a/xx b/xx new file mode 100755 index 0000000..11910cb --- /dev/null +++ b/xx @@ -0,0 +1,20 @@ +#!/bin/bash + +die() { + echo $@ + exit 1 +} + +VIMSTART=`dirname $0`/vimstart +[ -e "${VIMSTART}" ] || die "can't find vimstart program" + +FILES="" +while read LINE; do + if [ -e "${LINE}" ]; then + FILES="${FILES} ${LINE}" + else + echo "no such file as '${LINE}'" + fi +done + +${VIMSTART} ${FILES}