Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CS2] Add #! support for executable scripts on Linux. #3946

Merged
merged 51 commits into from
Jul 19, 2017
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6c48af3
Add #! support for executable scripts on Linux.
Apr 16, 2015
221dfc4
refactor option parsing
Apr 20, 2017
988f2af
address comments
Apr 20, 2017
fa3fe8b
intermediate save
May 24, 2017
aee066f
add note saying where OptionParser is used in coffee command
Apr 28, 2017
3c1fb7f
add some more work
May 24, 2017
a10c653
fix flatten functions
May 24, 2017
d5e8d74
Merge branch '2' of github.com:jashkenas/coffeescript
May 24, 2017
062fe62
Merge branch 'feature/uniform-hashbang-parsing'
May 24, 2017
c929ed9
refactor tests
May 31, 2017
b1acc4b
make argument processing less confusing
May 31, 2017
f3ea781
add basic test
May 31, 2017
200126f
Merge branch '2' into test/current-cli-optparse
May 31, 2017
7970e44
remove unused file
May 31, 2017
bc92ff3
compilation now hangs
May 31, 2017
7e0d9e0
remove unnecessary changes
Jun 2, 2017
0a05e0c
add tests!!!
Jun 2, 2017
3c49c8e
Merge branch '2' into feature/uniform-hashbang-parsing
Jun 2, 2017
0e1f27e
Merge branch 'test/current-cli-optparse' into feature/uniform-hashban…
Jun 2, 2017
42434b4
add/fix some tests
Jun 2, 2017
15eb624
clarify a test
Jun 2, 2017
bb9366c
Merge branch 'test/current-cli-optparse' into feature/uniform-hashban…
Jun 2, 2017
e1bcf84
fix helpers
Jun 9, 2017
7bc6591
fix opt parsing
Jun 9, 2017
7c4723d
fix infinite loop
Jun 9, 2017
768ada6
Merge remote-tracking branch 'upstream/2' into feature/uniform-hashba…
Jun 9, 2017
79c0e56
Merge remote-tracking branch 'upstream/2' into test/current-cli-optparse
Jun 9, 2017
ca7ad49
Merge branch 'test/current-cli-optparse' into feature/uniform-hashban…
Jun 9, 2017
daa5f4d
Merge remote-tracking branch 'upstream/2'
Jun 9, 2017
c75e2b1
Merge branch 'feature/uniform-hashbang-parsing'
Jun 9, 2017
23f31c6
Merge branch '2' of github.com:jashkenas/coffeescript
Jun 19, 2017
d495841
make rule building easier to read
Jun 19, 2017
bafa82f
add tests for flag overlap
Jun 19, 2017
9247444
revamp argument parsing again and add more thorough testing
Jun 19, 2017
b509b46
add tests, comment, clean unused method
Jun 19, 2017
31bbeb2
address review comments
Jun 20, 2017
7abe19c
Merge remote-tracking branch 'upstream/2'
Jun 21, 2017
3944d94
add test for direct invocation of shebang scripts
Jun 21, 2017
f41463d
move shebang parsing test to separate file and check for browser
Jun 21, 2017
356f3ad
remove TODO
Jun 21, 2017
7c17e23
example backwards compatible warnings
Jun 21, 2017
179687d
Merge remote-tracking branch 'upstream/2'
Jun 29, 2017
5b9b786
add correct tests for warning 1
Jun 29, 2017
8448a77
add tests for warnings
Jun 29, 2017
14df734
commit output js libs and update docs
Jun 29, 2017
b9291ae
respond to review comments
Jun 30, 2017
f306859
respond to review comments
Jul 7, 2017
4093574
Merge branch '2' of github.com:jashkenas/coffeescript
Jul 7, 2017
4856fd6
fix example output
Jul 7, 2017
f7e8c2b
Rewrite argument parsing documentation to be more concise; add it to …
GeoffreyBooth Jul 9, 2017
6fb80c1
Don’t mention deprecated syntax; clean up variable names
GeoffreyBooth Jul 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/optparse.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{repeat} = require './helpers'
{repeat, isCoffee} = require './helpers'

# A simple **OptionParser** class to parse option flags from the command-line.
# Use it like so:
Expand All @@ -25,6 +25,14 @@ exports.OptionParser = class OptionParser
# parsers that allow you to attach callback actions for every flag. Instead,
# you're responsible for interpreting the options object.
parse: (args) ->
# Pass all arguments to script unchanged if first argument is the script to
# be run; assume no options are for the coffeescript compiler. This allows
# the use of '#!/usr/bin/env coffee' to run executable scripts on Linux
# systems, which do not parse the '--' argument in the first line correctly.
if (args.indexOf '--' is -1) and
(args.length > 0) and
(isCoffee args[0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rewrite this is as

if args.length isnt 0 and '--' in args and isCoffee(args[0])

return arguments: args
options = arguments: []
skippingArgument = no
originalArgs = args
Expand Down