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

Shebang #345

merged 1 commit into from Feb 18, 2018


None yet
2 participants
Copy link

lorenzwalthert commented Feb 5, 2018

Aims to close #344. @jjramsey do you think the following regex is appropriate to identify hash-bang statements?


I first thought about including Rscript too but I think commands other than Rscript can be used in hash-bangs that can execute R, right? So it would be too specific. Alternatively, I thought about only looking at the first line of a file, but that seems to complicate things. The prosed regex will result in a few false positives though (see example #!NEED TO REMOVE THIS, which will be treated as hash-bang statement with the proposed regex).


This comment has been minimized.

Copy link

codecov-io commented Feb 5, 2018

Codecov Report

Merging #345 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #345      +/-   ##
+ Coverage    91.3%   91.35%   +0.04%     
  Files          30       30              
  Lines        1391     1399       +8     
+ Hits         1270     1278       +8     
  Misses        121      121
Impacted Files Coverage Δ
R/rules-spacing.R 96.07% <100%> (ø) ⬆️
R/expr-is.R 96.29% <100%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 961ac86...b77932c. Read the comment docs.

@lorenzwalthert lorenzwalthert force-pushed the lorenzwalthert:hash-bang branch from 9a4b4cb to 77e99ff Feb 10, 2018


This comment has been minimized.

Copy link
Collaborator Author

lorenzwalthert commented Feb 18, 2018

Ok, I think we can do it differently (better and simpler). Since a shebang statement will always be on the first line and hence a top-level expression, it will have pos_id 1 and we can simplify the regex to


@lorenzwalthert lorenzwalthert force-pushed the lorenzwalthert:hash-bang branch from 77e99ff to 8701bba Feb 18, 2018

@lorenzwalthert lorenzwalthert changed the title Hash bang Shebang Feb 18, 2018

@lorenzwalthert lorenzwalthert force-pushed the lorenzwalthert:hash-bang branch from 8701bba to b77932c Feb 18, 2018

@lorenzwalthert lorenzwalthert merged commit 49621d9 into r-lib:master Feb 18, 2018

4 checks passed

codecov/patch 100% of diff hit (target 91.3%)
codecov/project 91.35% (+0.04%) compared to 961ac86
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

@lorenzwalthert lorenzwalthert deleted the lorenzwalthert:hash-bang branch Feb 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.