Skip to content

Instantly share code, notes, and snippets.

@UndarkAido
Forked from jeremyBanks/expanded.md
Created June 21, 2017 17:32
Show Gist options
  • Select an option

  • Save UndarkAido/e7de8da039b26beb2d810e4be821bfa6 to your computer and use it in GitHub Desktop.

Select an option

Save UndarkAido/e7de8da039b26beb2d810e4be821bfa6 to your computer and use it in GitHub Desktop.

Revisions

  1. @jeremyBanks jeremyBanks revised this gist Jul 2, 2011. 2 changed files with 3 additions and 7 deletions.
    8 changes: 2 additions & 6 deletions expanded.md
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,6 @@ This check if there already is a compiled version newer than the source file. If

    ...we delete any existing version and then compile our code, using our chosen compiled filename.

    &&"$x" $*;
    &&exec "$x" "$@"

    If the compile was successful or unnecessary run the compiled code, passing on the arguments given to this script.

    exit

    We don't want `bash` to start evaluating our C code, so we quit.
    If the compile was successful or unnecessary, pass execution to the compiled code, passing on the arguments given to this script.
    2 changes: 1 addition & 1 deletion original.bash
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    //&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
    //&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&exec "$x" "$@"
  2. @jeremyBanks jeremyBanks revised this gist Jun 22, 2010. 2 changed files with 27 additions and 0 deletions.
    27 changes: 27 additions & 0 deletions expanded.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    //

    Since we don't want this visible in C, we put it in a comment.

    &>/dev/null

    Unfortunately `//` is interpreted as an invalid shell command and produces an error message, so we need to redirect that to `/dev/null` to get rid of it.

    ;x="${0%.*}"

    This determines what our compiled filename will be by using string replacement to get rid of any extensions on the current filename.

    ;[ ! "$x" -ot "$0" ]||

    This check if there already is a compiled version newer than the source file. If not...

    (rm -f "$x";cc -o "$x" "$0")

    ...we delete any existing version and then compile our code, using our chosen compiled filename.

    &&"$x" $*;

    If the compile was successful or unnecessary run the compiled code, passing on the arguments given to this script.

    exit

    We don't want `bash` to start evaluating our C code, so we quit.
    File renamed without changes.
  3. @jeremyBanks jeremyBanks created this gist Jun 22, 2010.
    1 change: 1 addition & 0 deletions original.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    //&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit