Skip to content

Instantly share code, notes, and snippets.

@little-forest
Last active April 19, 2018 01:16
Show Gist options
  • Select an option

  • Save little-forest/56593b7ceb55ae52e3142fc921d8144d to your computer and use it in GitHub Desktop.

Select an option

Save little-forest/56593b7ceb55ae52e3142fc921d8144d to your computer and use it in GitHub Desktop.
simple compile script
#!/bin/bash
SRC=$1
if [[ ! "$SRC" ]]; then
echo "第1引数にソースコードのファイル名を指定してください." >&2
exit 1
fi
if [[ ! -f "$SRC" ]]; then
echo "指定されたファイルが存在しません. : $SRC" >&2
exit 1
fi
OBJDIR=~/bin
if [[ ! -d "$OBJDIR" ]]; then
echo "出力先ディレクトリが存在しません. : $OBJDIR" >&2
exit 1
fi
OBJ=`basename "$SRC"`
OBJ=${OBJ%.*}
shift
gcc -o "$OBJDIR/$OBJ" "$SRC" && "$OBJDIR/$OBJ" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment