11 ms·
The fact that there is a "Won't do list" stating that functions won't be supported... I don't think this is anything more than a toy to play with rust.
by withjive 9y ago
The fact that there is a "Won't do list" stating that functions won't be supported...
I don't think this is anything more than a toy to play with rust.
- Brian_K_White 9y agoThis.
- valarauca1 9y agoGenerally speaking anytime you start to breakout bash/zsh/sh/csh functions you've already entered a zone where just writing a python/perl script would be the easier and a more maintainable solution in the long term.
- gkya 9y agoI have a dozen of functions in my bashrc that are basically a bit more sophisticated aliases. Why would I want to load a whole interpreter to run them while bash can easily do that?
- frou_dh 9y ago> I have a dozen of functions in my bashrc that are basically a bit more sophisticated aliases. Me too. Looking at them, they all start with something like test $# -eq 2 || return ...since in sh/bash you cannot even name your function's arguments or indicate how many you expect to receive. Speaking of primitiveness, in strict POSIX sh, there's no such thing as local variables in functions!!
- falcolas 9y agoNot if I want to actually affect the current shell environment. For example: export MARKPATH=$HOME/.marks function jump { cd -P $MARKPATH/$1 2> /dev/null || (echo "No such mark: $1" && marks) } function mark { mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1 } function unmark { rm -i $MARKPATH/$1 } function marks { ls -l $MARKPATH | sed 's/ / /g' | cut -d' ' -f9- && echo } _jump() { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "$( ls $MARKPATH )" -- $cur) ) } complete -F _jump jump This would be much harder to do in a script.
- eikenberry 9y agoShell functions are useful for much more than scripting. They are like aliases++, letting you add small commands to your shell where aliases don't quite cut it. They let you handle arguments, export environment variables, use conditionals, etc. I have 100 or so that I've added over the years. An interactive shell without functions would not cut it.
- IshKebab 9y agoOr the author justifiably thinks that a shell shouldn't support functions?
- ue_ 9y agoWhy shouldn't it? The shell is arguably the most convenient way to interact with your system's programs, seconded only by something like Perl. That level of interaction ought to mean you can write functions such as for common tasks. Or should I now have to use Perl for that?
- IshKebab 9y agoBecause fragile shell scripts have been an endless source of security vulnerabilities and bugs. I would probably use Python, Go or Powershell.
- sbmassey 9y agoYou can use functions outside of shell scripts - they can serve as a better kind of alias, or as a way of modifying the current shell without having to type the '.' before the script.
- naasking 9y agoShells languages arguably should be usable programming languages. So start with a good, expressive one add add scripting as a library: http://users.eecs.northwestern.edu/~jesse/pubs/caml-shcaml/ http://users.eecs.northwestern.edu/~jesse/pubs/caml-shcaml/ Incidentally, that would also dramatically decreased security and maintainability problems.