-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
Support built-in shell commands for an improved Windows support #197
Comments
Hi @lunny, So, this is something that was discussed before, and I actually wanted to solve this from the beginning, but it requires a considerable amount of work. You may want to take a look at mvdan/sh#93 and mvdan/sh#97. In short, it requires someone to implement these built-ins on the https://github.com/mvdan/sh project to make them work on Windows. It was also discussed before to just use https://github.com/ericlagergren/go-coreutils, but most of these implementations are done on a If anyone reading this issue is willing to help, let me know. Just make sure to sync with the author on mvdan/sh#93 before starting anything. |
Just found the issue I was looking for: ericlagergren/go-coreutils#114 |
I wonder if this is also useful ? You can inject what commands you want via a template approach too: |
Or cant we use the ones from Mage ? as a base ? |
Hi @gedw99,
Hmm... interesting project. It definitely have some core tools implemented. Would still require work, though, since these tools are
Mage fallsback to system tools just like Tusk. |
So, it's 2023 now, and there's no news? |
I found, as a workaround for the absolute most trivial use case of reading a file, which I would usually reach to e.g. vars:
VARIABLE:
sh: more "{{.FILE_TO_READ_INTO_VARIABLE}}" and that seems to populate the variable for Windows, macOS, and Linux (an Alpine instance). Still would love a more stable API, but this is one case that's common that I wouldn't know another easy solution without hacking together a |
Hey @andreynering, since it's been a while it might be worth a note in the docs? For example, in Platform specific tasks and commands we could say:
REF: mvdan/sh#93 |
Another approach could be to specify the required shell in the taskfile, so workarounds are more intentional and fail gracefully if the task can't execute. Similar to the We could also clean up the
Would, for instance, become:
|
If there's support among us for built-in commands, I can help out. By built-in commands, I mean using something like this, instead of flaky shelling: clean:
cmds:
- rmdir: ./builds/
- rm: ./packs/file.go
- cp: ./packs-backup/file.go ./packs/file.go
- mv: ./backup/manifest.xml ./site/ |
I personally like it! I dare say it would be easy enough to find the most commonly used parameters to avoid it becoming a shell replacement: https://discord.com/channels/974121106208354339/1025054680289660989/threads/1028716829981544559 |
I'm not contributor of this project, but I was looking for that. I personaly, like this approach "shell-agnostic" of finding the common uses. Having a full shell seems too overpower and complicated. With the above approach, we could expand the usage. Like, reading files, parsing JSON, replacing occurrence of strings, writing files and so on. We could create speciallized functions with different purposes: upload files, download. Similarly with github actions.
|
@pd93 what's the blocker for shell command support like this right now? Is it just time? |
Hey @leaanthony, it depends what kind of support we're talking about. If we're discussing foo:
cmds:
- mv ./a ./b Then this is still blocked by mvdan/sh#93. This is quite a chunk of work though and afaik no-one has had the bandwidth to work on it. The outstanding work would probably be done in u-root which is a dependency of mvdan/sh. The alternative to this is implementing support for some basic commands directly in Task using a syntax similar to what you suggested above. foo:
cmds:
- mv: ./a ./b While this is a good short-term solution, I would personally prefer proper shell support for the long-term for following reasons:
Having said all of that, it might be some time until we get shell support, so we might need to consider something in the short term. We could consider making it experimental? Though I don't want users to start depending on an experimental feature - especially one we know we're going to remove. In summary, the blocker here is resolving the above points and firmly deciding on a path forwards. After that, finding someone with some bandwidth to work on it :P @andreynering, do you have any thoughts on the above points? |
Thanks for the quick reply. The linked ticket hasn't been updated in 2 years so I don't think it's going to happen 😅 |
I think that the work required to build something like |
@leaanthony @andreynering The way I'm currently working around this issue, is to install https://github.com/uutils/coreutils on all platforms where I need the cross-platform commands. This works for me, but I realize other environments might be more constrained. |
For cross-platform usage, some built-in commands will helpful.
The text was updated successfully, but these errors were encountered: