1. 06 Dec, 2018 1 commit
    • Timothy Sample's avatar
      Use git-version-gen for versioning · acaaa3c3
      Timothy Sample authored
      * build-aux/git-version-gen: New file.
      * .gitignore: Do not ignore it.
      * configure.ac: Use it to generate the version string.
      * guix.scm: Ditto.
      * Makefile.am: Make .tarball-version.
      acaaa3c3
  2. 05 Dec, 2018 39 commits
    • Timothy Sample's avatar
      Add support for $$ · 177953c4
      Timothy Sample authored
      * geesh/environment.scm (*root-pid*): New variable.
      (get-root-pid): New public function.
      * geesh/word.scm (parameter-ref): Handle '$'.
      177953c4
    • Timothy Sample's avatar
      Initialize $PWD properly · 6b38897d
      Timothy Sample authored
      * geesh/environment.scm (initial-pwd): New function.
      (initial-variables): New function.
      (*variables*): Initialize to the result of initial-variables.
      6b38897d
    • Timothy Sample's avatar
      Work around missing case expressions · 2db92dd2
      Timothy Sample authored
      * geesh/eval.scm (exps->thunk): Filter out '#f' expressions.
      2db92dd2
    • Timothy Sample's avatar
      Set search paths explicitly in the geesh script · 9fd1eb9e
      Timothy Sample authored
      * configure.ac: Do not treat scripts/geesh as an AC_CONFIG_FILE.
      * Makefile.am: Do the substitutions here (at make-time).
      * scripts/geesh.in: Update %load-path and %load-compiled-path
      explicitly before loading anything.
      9fd1eb9e
    • Timothy Sample's avatar
      Add the trap built-in · 79e5c6ea
      Timothy Sample authored
      * geesh/built-ins/trap.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*special-built-ins*): Add trap.
      79e5c6ea
    • Timothy Sample's avatar
      Add the return and exit built-ins · 3769dce5
      Timothy Sample authored
      * geesh/built-ins/return.scm: New file.
      * geesh/built-ins/exit.scm: New file.
      * geesh/Makefile.am: Add them.
      * geesh/built-ins.scm (*special-built-ins*): Add return and exit.
      3769dce5
    • Timothy Sample's avatar
      Add return and exit semantics · 66e89c1a
      Timothy Sample authored
      * geesh/environment.scm (*return-tag*): New variable.
      (call-with-return): New public function.
      (sh:return): New public function.
      (*atexit*): New variable.
      (*exiting?*) New variable.
      (set-atexit!): New public function.
      (sh:exit): New public function.
      * geesh/repl.scm (run-repl): Call sh:exit at the end of a script.
      * geesh/shell.scm (sh:exec-let): Use call-with-return for functions.
      * geesh/built-ins/dot.scm (main): Use call-with-return.
      66e89c1a
    • Timothy Sample's avatar
      Add a prefix to break and continue · 2fdbfe2c
      Timothy Sample authored
      These names are too common, and it will be even worse with 'exit'
      and 'return'.
      
      * geesh/environment.scm (break): Rename this...
      (sh:break) ...to this.
      (continue): Rename this...
      (sh:continue) ...to this.
      * geesh/built-ins/break.scm (main): Update call.
      * geesh/built-ins/continue.scm (main): Ditto.
      2fdbfe2c
    • Timothy Sample's avatar
      Handle here-documents everywhere · 118750bb
      Timothy Sample authored
      This commit fixes a problem with the old method of handling
      here-documents.  We used to ignore here-documents in many places where
      they are valid (e.g., between Boolean operators).  They are now valid
      after any 'NEWLINE' token.  To achieve this, the handling logic was
      moved out of the parser and into the lexer.  We now use a hook
      mechanism to manage the necessary communication between the parser and
      lexer.
      
      * geesh/parser.scm (read-here-docs): Return strings instead of tokens.
      (make-lexer): Add here-docs-hook as a keyword argument, and call it
      after reading here-documents.
      (make-parser): Let command-hooks transform commands, and remove
      here-document handling rules.
      (parse): Handle merging here-documents into commands.
      * tests/parser.scm: Add tests for many less-intuitive here-document
      locations.
      118750bb
    • Timothy Sample's avatar
      Factor out common code from the read-sh functions · 8774eec5
      Timothy Sample authored
      * geesh/parser.scm (make-lexer): Remove the read-sh/bracketed and
      read-sh/backquoted parameters.
      (parse): New function.
      (->command-list): New function.
      (read-sh/bracketed, read-sh/backquoted, read-sh, read-sh-all):
      Simplify by using the new functions.
      8774eec5
    • Timothy Sample's avatar
      Handle argument special parameters · c64d16f4
      Timothy Sample authored
      * geesh/word.scm (parameter-ref): Handle numeric argument parameters
      and the argument count parameter ('$#').
      c64d16f4
    • Timothy Sample's avatar
      Add the exec built-in · 2543ecd2
      Timothy Sample authored
      * geesh/built-ins/exec.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*special-built-ins*): Add exec.
      2543ecd2
    • Timothy Sample's avatar
      Add the umask built-in · bacbb436
      Timothy Sample authored
      * geesh/built-ins/umask.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*built-ins*): Add umask.
      bacbb436
    • Timothy Sample's avatar
      Add the shift built-in · a7c5d8cc
      Timothy Sample authored
      * geesh/built-ins/shift.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*special-built-ins*): Add shift.
      a7c5d8cc
    • Timothy Sample's avatar
      Fix handling of unknown options in set · bc7e876f
      Timothy Sample authored
      * geesh/built-ins/set.scm (main): Continue processing options as new
      arguments (i.e., 'set -- ...') after encountering an unknown option.
      bc7e876f
    • Timothy Sample's avatar
      Allow more character range patterns · 2bcef528
      Timothy Sample authored
      * geesh/pattern.scm (ascii-lower-case, ascii-upper-case, asii-digits):
      Remove variables.
      (character-range): New function.
      (parse-matching-bracket-expression): Use it to allow any character
      range contained in one of the ASCII uppercase, ASCII lowercase, or
      ASCII digits character sets.
      2bcef528
    • Timothy Sample's avatar
      Add the dot and eval built-ins · c1f8a870
      Timothy Sample authored
      * geesh/built-ins/utils.scm (get-evaluator): New public function.
      * geesh/built-ins/dot.scm: New file.
      * geesh/built-ins/eval.scm: New file.
      * geesh/Makefile.am: Add them.
      * geesh/built-ins.scm (*special-built-ins*): Add dot and eval.
      c1f8a870
    • Timothy Sample's avatar
      Enable a test from the redirect spec. tests · 6a68c73a
      Timothy Sample authored
      * tests/spec/oil.scm: Enable a redirect test that requires errexit.
      6a68c73a
    • Timothy Sample's avatar
      Enable the errexit specification test · 0ec3ed02
      Timothy Sample authored
      * tests/spec/Makefile.am (TESTS): Add errexit.
      * tests/spec/oil.scm: Filter and modify five of its tests.
      0ec3ed02
    • Timothy Sample's avatar
      Respect the errexit option · 50328c8c
      Timothy Sample authored
      * geesh/shell.scm (ignore-errexit?): New parameter.
      (without-errexit): New function.
      (errexit): New function.
      (sh:exec-let, sh:set-redirects, sh:with-redirects, sh:subshell,
      sh:substitute-command, sh:pipeline, sh:and, sh:or, sh:not, sh:while,
      sh:cond): Use it to exit on nonzero status.
      50328c8c
    • Timothy Sample's avatar
      Process options passed to the set built-in · af759319
      Timothy Sample authored
      * geesh/built-ins/set.scm (option?): New function.
      (option-letter?): New function.
      (set-option!): New function.
      (main): Set or print options as specified by the given arguments.
      * tests/spec/oil.scm: Filter out a redirect test that was only passing
      because set did not work.
      af759319
    • Timothy Sample's avatar
      Add options to the environment · c83dbcbd
      Timothy Sample authored
      * geesh/environment.scm (*options*): New variable.
      (getopt): New public function.
      (setopt!): New public function.
      (*option-names*): New public variable.
      (*option-letters*): New public variable.
      c83dbcbd
    • Timothy Sample's avatar
      Exit subshells with the current status · b4a63508
      Timothy Sample authored
      * geesh/shell.scm (%subshell): Use with-continuation-barrier and
      primitive-exit to make sure the child process exits with its status.
      b4a63508
    • Timothy Sample's avatar
      Set status to 0 when all sh-cond tests fail · 77f3113f
      Timothy Sample authored
      * geesh/shell.scm (sh:cond): If no body thunk is called, set the
      status to 0.
      77f3113f
    • Timothy Sample's avatar
      Handle command not found with status 127 · 8c061471
      Timothy Sample authored
      * geesh/shell.scm (sh:exec-let): Print a message and set the status to
      127 when path search fails.
      * tests/shell.scm: Update test.
      8c061471
    • Timothy Sample's avatar
      Add the colon built-in · 2c1dd2d6
      Timothy Sample authored
      * geesh/built-ins/colon.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*special-built-ins*): Add colon.
      2c1dd2d6
    • Timothy Sample's avatar
      Pass options through when running spec. tests · 36e4811d
      Timothy Sample authored
      tests/spec/Makefile.am (oil/bin/geesh): Pass options through.
      36e4811d
    • Timothy Sample's avatar
      Add basic option processing to the main script · a1bd8d06
      Timothy Sample authored
      * geesh/repl.scm (run-repl): Add optional port parameter.
      * scripts/geesh.in: Add '--command' and '--stdin' flags, and if
      neither flag is provided, treat the first argument as a file to
      interpret.
      a1bd8d06
    • Timothy Sample's avatar
      Add the cd and pwd built-ins · 271301e7
      Timothy Sample authored
      * geesh/built-ins/cd.scm: New file.
      * geesh/built-ins/pwd.scm: New file.
      * Makefile.am: Add them.
      * geesh/built-ins.scm (*built-ins*): Add cd and pwd.
      271301e7
    • Timothy Sample's avatar
      Globalize the environment module · 4ef69078
      Timothy Sample authored
      Instead of passing around references to the environment, just treat it
      as a global.  The old way was just the remains of an idea to make the
      environment immutable and keep the interpreter from manipulating any
      global state.  By making everything global and mutable, we will have
      less impedance mismatch with POSIX going forward.
      
      The following changelog is only a sketch, since nearly every function
      has changed.
      
      * geesh/environment.scm: Replace this module with one that treats the
      environment as a global resource.
      * tests/environment.scm: Delete file.
      * Makefile.am: Remove it from the list of tests.
      * geesh/shell.scm, geesh/eval.scm, geesh/repl.scm, geesh/word.scm,
      geesh/built-ins/break.scm, geesh/built-ins/continue.scm,
      geesh/built-ins/echo.scm, geesh/built-ins/export.scm,
      geesh/built-ins/false.scm, geesh/built-ins/read.scm,
      geesh/built-ins/readonly.scm, geesh/built-ins/set.scm,
      geesh/built-ins/true.scm, geesh/built-ins/unset.scm: Remove 'env'
      parameters and use the new environment module.
      * .dir-locals.el: Update indentation of functions that no longer take
      an 'env' parameter and add with-arguments, with-environ, and
      with-variables from the new environment module.
      * tests/shell.scm, tests/word.scm: Update environment creation and
      manipulation in tests.
      4ef69078
    • Timothy Sample's avatar
      Enable 'loop' specification test · dd64f223
      Timothy Sample authored
      * tests/spec/Makefile.am (TESTS): Add 'loop'.
      * tests/spec/oil.scm: Remove one test and patch four others.
      dd64f223
    • Timothy Sample's avatar
      Add the set built-in · 0d41cec2
      Timothy Sample authored
      * geesh/environment.scm: Export set-environment-arguments!.
      * geesh/built-ins/set.scm: New file.
      * Makefile.am: Add them.
      * geesh/built-ins.scm: Add set.
      0d41cec2
    • Timothy Sample's avatar
      Enable 'case_' specification test · a5a1f85a
      Timothy Sample authored
      * tests/spec/Makefile.am (TESTS): Add 'case_'.
      * tests/spec/oil.scm: Filter out two Bash-specific tests.
      a5a1f85a
    • Timothy Sample's avatar
      Add readonly built-in · 671a9260
      Timothy Sample authored
      * geesh/built-ins/utils.scm: New file.
      * geesh/built-ins/readonly.scm: New file.
      * Makefile.am: Add them.
      * geesh/built-ins/export.scm (split-assignments): Move to utils.
      * geesh/built-ins.scm (*special-built-ins*): Add readonly.
      671a9260
    • Timothy Sample's avatar
      Check for EOF in read built-in · c5ac41b0
      Timothy Sample authored
      * geesh/built-ins/read.scm (main): Check for EOF.
      c5ac41b0
    • Timothy Sample's avatar
      Add the export built-in · 279ef0cd
      Timothy Sample authored
      * geesh/built-ins/export.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*special-built-ins*): Add export.
      279ef0cd
    • Timothy Sample's avatar
      Add export and read-only attributes to variables · e784aaa6
      Timothy Sample authored
      * geesh/environment.scm (<variable>): New record type.
      (make-environment): Initialize variables as records.
      (var-ref): Extract value from record.
      (set-var!): Inject value into record and throw an error if variable
      is read-only.
      (set-var-export!): New public function.
      (set-var-read-only!): New public function.
      (environment->environ): Only include exported variables.
      e784aaa6
    • Timothy Sample's avatar
      Add 'true' built-in · d4bb8ae4
      Timothy Sample authored
      * geesh/built-ins/true.scm: New file.
      * Makefile.am: Add it.
      * geesh/built-ins.scm (*built-ins*): Add true.
      d4bb8ae4
    • Timothy Sample's avatar
      Add case and cond support · eae9857f
      Timothy Sample authored
      * geesh/eval.scm (eval-sh) Handle '<sh-case>' and '<sh-cond>' cases.
      eae9857f