Permalink
Browse files

Rename the oilc command to oshc.

oilc will be for the Oil language!

- oshc deps and oshc translate sort of work.
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 4, 2018
1 parent 5007894 commit b74c1e5c533076e67936f40a607ae8cf02529741
Showing with 45 additions and 44 deletions.
  1. +16 −15 bin/oil.py
  2. +1 −1 build/common.sh
  3. +1 −1 install
  4. +27 −27 test/{oilc.sh → oshc-deps.sh}
View
@@ -85,6 +85,7 @@ def _tlog(msg):
else:
completion = None
from tools import deps
from tools import osh2oil
log = util.log
@@ -195,7 +196,7 @@ def OshMain(argv0, argv, login_shell):
default='abbrev-text')
spec.LongFlag('--show-ast') # execute and show
spec.LongFlag('--fix')
spec.LongFlag('--debug-spans')
spec.LongFlag('--debug-spans') # For oshc translate
spec.LongFlag('--print-status')
spec.LongFlag('--trace', ['cmd-parse', 'word-parse', 'lexer']) # NOTE: can only trace one now
spec.LongFlag('--hijack-shebang')
@@ -471,15 +472,15 @@ def BoilMain(main_argv):
# TODO: Hook up to completion.
SUBCOMMANDS = ['translate', 'format', 'deps', 'undefined-vars']
def OilCommandMain(argv):
"""Run an 'oilc' tool.
def OshCommandMain(argv):
"""Run an 'oshc' tool.
'oilc' is short for "oil compiler" or "oil command".
'osh' is short for "osh compiler" or "osh command".
TODO:
- oilc --help
- oshc --help
oilc deps
oshc deps
--path: the $PATH to use to find executables. What about libraries?
NOTE: we're leaving out su -c, find, xargs, etc.? Those should generally
@@ -489,10 +490,10 @@ def OilCommandMain(argv):
try:
action = argv[0]
except IndexError:
raise args.UsageError('oilc: Missing required subcommand.')
raise args.UsageError('oshc: Missing required subcommand.')
if action not in SUBCOMMANDS:
raise args.UsageError('oilc: Invalid subcommand %r.' % action)
raise args.UsageError('oshc: Invalid subcommand %r.' % action)
try:
script_name = argv[1]
@@ -542,11 +543,11 @@ def OilCommandMain(argv):
# stderr: show how we're following imports?
from tools import deps
if action == 'translate':
# TODO: osh2oil. Remove opts.fix
pass
# TODO: FIx this invocation up.
#debug_spans = opt.debug_spans
debug_spans = False
osh2oil.PrintAsOil(arena, node, debug_spans)
elif action == 'format':
# TODO: autoformat code
@@ -566,7 +567,7 @@ def OilCommandMain(argv):
# The valid applets right now.
# TODO: Hook up to completion.
APPLETS = ['osh', 'oilc']
APPLETS = ['osh', 'oshc']
def AppBundleMain(argv):
@@ -606,8 +607,8 @@ def AppBundleMain(argv):
status = OshMain(argv0, main_argv, login_shell)
_tlog('done osh main')
return status
elif main_name == 'oilc':
return OilCommandMain(main_argv)
elif main_name == 'oshc':
return OshCommandMain(main_argv)
elif main_name == 'oil':
return OilMain(main_argv)
View
@@ -19,7 +19,7 @@ readonly PY27=Python-2.7.13
readonly PREPARE_DIR=_devbuild/cpython-full
# Used by scripts/run.sh and opy/build.sh
readonly OIL_SYMLINKS=(oil oilc osh sh wok boil true false)
readonly OIL_SYMLINKS=(oil osh oshc sh wok boil true false)
log() {
View
@@ -34,7 +34,7 @@ main() {
fi
cd $PREFIX/bin
for link in osh oilc; do
for link in osh oshc; do
if ! ln -s -f $exec_filename $link; then # -f to overwrite
die "Couldn't create $link symlink"
fi
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Usage:
# ./oilc.sh <function name>
# ./oshc-deps.sh <function name>
set -o nounset
set -o pipefail
@@ -11,74 +11,74 @@ source test/common.sh
# TODO: We need a common test framework for command-line syntax of bin/*. The
# spec tests are doing that now with $SH.
# osh2oil should be oilc translate.
# osh2oil should be oshc translate.
# Compare osh code on stdin (fd 0) and expected oil code on fd 3.
assert-deps() {
bin/oilc deps | diff -u /dev/fd/3 - || fail
bin/oshc deps | diff -u /dev/fd/3 - || fail
}
usage() {
set +o errexit
set +o errexit
# missing required subcommand
bin/oilc
bin/oshc
test $? -eq 2 || fail
bin/oilc invalid
bin/oshc invalid
test $? -eq 2 || fail
# Syntax error
echo '<' | bin/oilc deps
# Syntax error
echo '<' | bin/oshc deps
test $? -eq 2 || fail
# File not found
bin/oilc deps nonexistent.txt
# File not found
bin/oshc deps nonexistent.txt
test $? -eq 2 || fail
return
return
# Doesn't work yet
echo --
bin/oilc --help
# Doesn't work yet
echo --
bin/oshc --help
test $? -eq 0 || fail
set -o errexit
set -o errexit
}
deps() {
bin/oilc deps $0
bin/oshc deps $0
test $? -eq 0 || fail
# Have to go inside a condition
assert-deps <<EOF 3<<DEPS
# Have to go inside a condition
assert-deps <<EOF 3<<DEPS
if { grep foo bar; } then
cat hi
cat hi
fi
EOF
grep
cat
DEPS
# g is used textually before defined, but that's OK
assert-deps <<EOF 3<<DEPS
# g is used textually before defined, but that's OK
assert-deps <<EOF 3<<DEPS
f() {
g
g
}
g() {
echo G
echo G
}
f
grep foo bar
EOF
grep
DEPS
# g is used before defined, NOT OK
assert-deps <<EOF 3<<DEPS
# g is used before defined, NOT OK
assert-deps <<EOF 3<<DEPS
g
g() {
echo G
echo G
}
grep foo bar
EOF
@@ -100,7 +100,7 @@ all-passing() {
done
echo
echo "All osh2oil tests passed."
echo "All $0 tests passed."
}

0 comments on commit b74c1e5

Please sign in to comment.