From 435e4038e090576c3b9d0d8b43fd56546653d717 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Mon, 24 May 2010 16:04:07 -0700 Subject: [PATCH] Add vimstart --- Makefile | 2 ++ vimstart.c | 16 ++++++++++++++++ xx | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 0 deletions(-) create mode 100644 vimstart.c create mode 100755 xx 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} -- 1.6.6.rc1.39.g9a42