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

Run shellscript as such #609

Merged
merged 4 commits into from
Jun 6, 2024
Merged

Run shellscript as such #609

merged 4 commits into from
Jun 6, 2024

Conversation

sourishkrout
Copy link
Member

@sourishkrout sourishkrout commented Jun 6, 2024

In the extension when the languageID set to shellscript, it's being rewritten to sh. However, only after serialization following the initial deserialization. To deal with this edge-case let's be sure we run shellscript as such. Prior to this fix it would default to cat (shebang++) which is wrong.

PS: Interestingly this is already fixed in v2alpha1 and the code in this PR is exclusively for v1.

@adambabik
Copy link
Collaborator

PS: Interestingly this is already fixed in v2alpha1 and the code in this PR is exclusively for v1.

It's because shellscript was added to the interpreterByLanguageID map. I think it's still worth to add a test in internal/command/command_file_test.go:

--- a/internal/command/command_file_test.go
+++ b/internal/command/command_file_test.go
@@ -27,6 +27,20 @@ func TestFileCommand(t *testing.T) {
                testExecuteCommand(t, cfg, nil, "test", "")
        })
 
+       t.Run("Shellscript", func(t *testing.T) {
+               t.Parallel()
+
+               cfg := &ProgramConfig{
+                       LanguageId: "shellscript",
+                       Source: &runnerv2alpha1.ProgramConfig_Script{
+                               Script: `echo "run this as shell script"`,
+                       },
+                       Mode: runnerv2alpha1.CommandMode_COMMAND_MODE_FILE,
+               }
+
+               testExecuteCommand(t, cfg, nil, "run this as shell scripta\n", "")
+       })
+
        t.Run("Python", func(t *testing.T) {
                t.Parallel()

@sourishkrout
Copy link
Member Author

Done in 945dd14 @adambabik.

@sourishkrout sourishkrout removed the request for review from pastuxso June 6, 2024 20:59
Copy link

sonarcloud bot commented Jun 6, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@sourishkrout sourishkrout merged commit 53cf215 into main Jun 6, 2024
6 checks passed
@sourishkrout sourishkrout deleted the seb-shellscript-sh branch June 6, 2024 21:07
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.

2 participants