Earlier quoted context omitted.
I find it hilarious that there's a ruby version of a tool that can be implemented in 10 lines of bash. It's like atwood's law all over again. Use the right tool for the job, please.
I'd be happy to see your 10 lines bash version of this ruby tool, with the same options/properties (debug messages, customizable prompt, history logging, same safeguards, rlwrap support, man page).
Show HN: Replify – Create a REPL for any command
11–20 of 20 posts
Re: Show HN: Replify – Create a REPL for any command
#12Another generic `repl` utility, this one in ruby: https://github.com/defunkt/repl
afaik, it will work just about anywhere you can invoke a shell (i haven't tested it all that extensively)
Re: Show HN: Replify – Create a REPL for any command
#13Earlier quoted context omitted.
I'd be happy to see your 10 lines bash version of this ruby tool, with the same options/properties (debug messages, customizable prompt, history logging, same safeguards, rlwrap support, man page).
You're missing the point. I could do all of that in a similar (or likely smaller) number of lines with bash compared to the ruby tool, only mine would be much faster and wouldn't depend on the enormous ruby runtime.
to do so however didn't just require a similar number of lines, it actually required 4 more (though to be fair, both scripts have comments and a fair bit of formatting, so it may not be a fair comparison. also it probably doesn't need stating, but i'm a bit of a hack, so my implementation maybe shouldn't be the reference point. but i digress)
in any event, i don't think atwood's law comes into play, given that a) this isn't in javascript and b) defunkt is a well known member of the ruby community who spends a lot of time working in ruby and probably wrote this to actually use it, as quickly as he could think of it. his choice of language here is perfectly reasonable in that context.
if you remain convinced that the only correct language for such a tool is bash/shell, i imagine OP certainly welcomes PRs; i know i do.
Re: Show HN: Replify – Create a REPL for any command
#14Earlier quoted context omitted.
I'd be happy to see your 10 lines bash version of this ruby tool, with the same options/properties (debug messages, customizable prompt, history logging, same safeguards, rlwrap support, man page).
You're missing the point. I could do all of that in a similar (or likely smaller) number of lines with bash compared to the ruby tool, only mine would be much faster and wouldn't depend on the enormous ruby runtime.
Re: Show HN: Replify – Create a REPL for any command
#15Here is my version: #!/bin/bash printf "REPL for %s\n" "$@" notblank() { [ $# -gt 0 ] } while true ; do printf "%s> " "$@" read -r || break; notblank $REPLY || continue; eval command \"\$@\" "$REPLY" done We keep the original parameters and expand them with "$@". There is a Bash feature that read with no args reads the line into the REPLY variable. We want that to be subject to splitting. If $REPLY expands to nothing…
Re: Show HN: Replify – Create a REPL for any command
#16Here is my version: #!/bin/bash printf "REPL for %s\n" "$@" notblank() { [ $# -gt 0 ] } while true ; do printf "%s> " "$@" read -r || break; notblank $REPLY || continue; eval command \"\$@\" "$REPLY" done We keep the original parameters and expand them with "$@". There is a Bash feature that read with no args reads the line into the REPLY variable. We want that to be subject to splitting. If $REPLY expands to nothing…
EDIT: beat to the punch, should've refreshed.
Re: Show HN: Replify – Create a REPL for any command
#17Neat trick - the only change I made is to exit the while loop by typing "exit". That way the enter key runs the command with no arguments, and you can exit with control+c or by typing "exit".
Re: Show HN: Replify – Create a REPL for any command
#18Re: Show HN: Replify – Create a REPL for any command
#19Neat trick - the only change I made is to exit the while loop by typing "exit". That way the enter key runs the command with no arguments, and you can exit with control+c or by typing "exit".
And what if you want "exit" as argument. You should think bigger in general if your into tooling for others....