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

Shebang #345

merged 1 commit into from Feb 18, 2018


Copy link

@lorenzwalthert 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).

Copy link

@codecov-io 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.

Copy link
Collaborator Author

@lorenzwalthert 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 changed the title Hash bang Shebang Feb 18, 2018
@lorenzwalthert lorenzwalthert merged commit 49621d9 into r-lib:master Feb 18, 2018
4 checks passed
@lorenzwalthert lorenzwalthert deleted the hash-bang branch Feb 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants