dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 8be0afc7b3c48eb5bd8f975c94b360fcffd7d4d5
parent b31117719ae4b6285f45dad29026e535487a0bf0
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 25 Jul 2019 18:18:21 +0200

Make crun POSIX compatible

Diffstat:
M.local/bin/crun | 26+++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/.local/bin/crun b/.local/bin/crun @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # CRUN compiles C/C++ code to a temporary file, and executes it. # Author: Anders Damsgaard, andersd@risup.net @@ -17,23 +17,23 @@ tmpname=/tmp/$filename # Check if the corresponding file is older than the source # and recompile it if that's the case. # arg 1: compiler, arg 2: source code file -function compile { - if [ -e "$tmpname" ]; then - if [[ $2 -nt $tmpname ]]; then - $1 "$2" -o "$tmpname" "$CFLAGS" "$3" "$4" "$5" "$6" "$7" "$8" "$9" - fi - else - $1 "$2" -o "$tmpname" "$CFLAGS" "$3" "$4" "$5" "$6" "$7" "$8" "$9" - fi +compile() { + if [ -e "$tmpname" ]; then + if test "$2" -nt "$tmpname"; then + $1 "$2" -o "$tmpname" "$CFLAGS" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + fi + else + $1 "$2" -o "$tmpname" "$CFLAGS" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + fi } # Compile source to file in /tmp -if [ "$extension" == "c" ]; then - compile $CC "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" +if [ "$extension" = "c" ]; then + compile $CC "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" fi -if [ "$extension" == "cpp" ]; then - compile $CXX "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" +if [ "$extension" = "cpp" ]; then + compile $CXX "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" fi $tmpname