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

condition_script behaves differently from other scripts blocks #987

Closed
wmmc88 opened this issue Nov 12, 2023 · 8 comments
Closed

condition_script behaves differently from other scripts blocks #987

wmmc88 opened this issue Nov 12, 2023 · 8 comments
Assignees

Comments

@wmmc88
Copy link
Contributor

wmmc88 commented Nov 12, 2023

Describe The Bug

It seems that condition_script works differently from all other script block types. As seen in the first block below, it looks like it doesn't support things like duckscript shebangs. As seen in the 2nd block, it looks like it doesn't execute each block as a seperate script (unlike env_scripts even though the syntax is a array of strings).

To Reproduce

[tasks.no-shebang]
condition_script = [
'''
#!@duckscript

if 0
  exit 1
end
'''
]
script = '''
#!@duckscript
echo success!!
'''

[tasks.single-exec]
condition_script = [
"echo hello?",
"exit 0",
"exit 1",
]
script = '''
#!@duckscript
echo success!!
'''

Error Stack

🪟 Windows 11 Enterprise(10.0.23580) (pwsh) D:\git-repos
at 06:07:24 PM ❯ cargo make no-shebang
[cargo-make] INFO - cargo make 0.37.4
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: no-shebang
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration

D:\git-repos>#!@duckscript
'#!@duckscript' is not recognized as an internal or external command,
operable program or batch file.

D:\git-repos>cd "D:\git-repos"
The syntax of the command is incorrect.
D:\git-repos>if 0
[cargo-make] INFO - Skipping Task: no-shebang 
[cargo-make] INFO - Build Done in 0.63 seconds.
🪟 Windows 11 Enterprise(10.0.23580) (pwsh) D:\git-repos
at 06:11:13 PM ❯ cargo make single-exec
[cargo-make] INFO - cargo make 0.37.4
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: single-exec
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration

D:\git-repos>cd "D:\git-repos"

D:\git-repos>echo hello?
hello?

D:\git-repos>exit 0
[cargo-make] INFO - Running Task: single-exec
success!! 
[cargo-make] INFO - Build Done in 0.33 seconds.
@wmmc88
Copy link
Contributor Author

wmmc88 commented Jan 17, 2024

@sagiegurari any chance that there'll be @duckscript/@rust shebang support in condition_script?

@sagiegurari
Copy link
Owner

@wmmc88 sorry for taking so long. i actually remember taking a look at it and it wasn't a quick fix so didn't have time for it.
i'll try to recheck this weekend

@sagiegurari
Copy link
Owner

@wmmc88 can you validate this works well in the dev branch: 0.37.8

@wmmc88
Copy link
Contributor Author

wmmc88 commented Jan 19, 2024

@sagiegurari Using the no-shebang task example above, I get the following error:

cargo make --no-workspace no-shebang

[cargo-make] INFO - cargo make 0.37.7
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: no-shebang
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
D:\git-repos\github\windows-drivers-rs.git\worktrees-folder\arm64-improvements>#!@duckscript
'#!@duckscript' is not recognized as an internal or external command,
operable program or batch file.

D:\git-repos\github\windows-drivers-rs.git\worktrees-folder\arm64-improvements>cd "D:\git-repos\github\windows-drivers-rs.git\worktrees-folder\arm64-improvements"
The syntax of the command is incorrect.
D:\git-repos\github\windows-drivers-rs.git\worktrees-folder\arm64-improvements>if 0
[cargo-make] INFO - Skipping Task: no-shebang
[cargo-make] INFO - Build Done in 1.04 seconds.

@wmmc88
Copy link
Contributor Author

wmmc88 commented Jan 19, 2024

i did confirm however that sagiegurari/duckscript#390 was resolved.

@sagiegurari
Copy link
Owner

@wmmc88 are you sure you tried the right version? did you install it from the github branch?
because i added this example and it works well

[tasks.test-duckscript-condition]
condition_script = ['''
#!@duckscript
var = set "hello from duckscript"
echo ${var}
echo %{var}
exit 0
''']
script = '''
echo "duckscript condition was met"
'''

@wmmc88
Copy link
Contributor Author

wmmc88 commented Jan 22, 2024

@sagiegurari Ah. it seems like i had a stale git branch that I installed from. I can confirm that duckscript runner works now!

The second part of this issue was that the syntax for condition_script has [/]. I find this odd since script doesnt require it. env_scripts requires it, but that's because env_scripts accepts multiple different scripts, while it looks like condition_script only allows one. Not sure if you want to make a change there, but i think this inconsistency can be annoying for new users.

@sagiegurari
Copy link
Owner

released new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants