Skip to content

Conversation

@PsiACE
Copy link
Member

@PsiACE PsiACE commented Aug 10, 2024

Which issue does this PR close?

Closes #11880 .

Rationale for this change

What changes are included in this PR?

to support traditional #! ... shebangs

#!/usr/bin/env -S datafusion-cli -f
SELECT 1;

or we can use something like

--() { :; }; exec datafusion-cli -f "$0"
SELECT 1;

Are these changes tested?

Are there any user-facing changes?

Signed-off-by: Chojan Shang <psiace@apache.org>
@alamb alamb changed the title Ingore shebang at top of file Ingore shebang at top of file in datafusion-cli Aug 11, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @PsiACE !

I tested this manually

Before this PR:

andrewlamb@Andrews-MBP-2:~/Software/datafusion/datafusion-cli$ datafusion-cli  -f /tmp/foo.sql
DataFusion CLI v40.0.0
SQL error: ParserError("Expected: an SQL statement, found: #!")

With this PR:

andrewlamb@Andrews-MBP-2:~/Software/datafusion/datafusion-cli$ cargo run -- -f /tmp/foo.sql
...
DataFusion CLI v41.0.0
+----------+
| Int64(1) |
+----------+
| 1        |
+----------+
1 row(s) fetched.
Elapsed 0.008 seconds.

@PsiACE
Copy link
Member Author

PsiACE commented Aug 11, 2024

I tested this manually

I'm glad to see you confirmed it works manually. I hadn't thought about supporting #! , but I use fish as my default shell and something like --() wasn't generic enough.

@alamb alamb merged commit fd237f8 into apache:main Aug 11, 2024
@alamb
Copy link
Contributor

alamb commented Aug 11, 2024

Thanks again @PsiACE

@PsiACE PsiACE deleted the shebang branch August 11, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

datafusion-cli: ignore hashbang at top of script

2 participants