-2

I am getting crazy, on my Linux machine I would run:

yes 0 | script -c 'ispell text.txt' /dev/null

With any problem. Unfortunately on Mac OS X the command script is not accepting the '-c' option:

script: illegal option -- c

I installed with brew: binutils, coreutils and other packages .. but there is no script or script alternative command anywhere.

I found on Google that the package under Linux is util-linux: https://www.kernel.org/pub/linux/utils/util-linux/

But there is no way to find it for mac OS X nor in a compiled package nor in brew source.

Could anyone please point me to the right direction?

PS: my final aim is to achieve this: Spell checking a file using command line, non-interactively

Community
  • 1
  • 1
shaice
  • 39
  • 4
  • 1
    What is `script`? bash DOES support `-c`, as does any POSIX compatible shell. – Andreas Louv Oct 31 '16 at 11:47
  • Unfortunately '-c' is not supported by the bash bundled with Mac OS X Sierra, neither by the one within brew.... – shaice Oct 31 '16 at 11:48
  • Reading the man page for OSX bashsays otherwide: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/bash.1.html – Andreas Louv Oct 31 '16 at 11:50
  • The command is 'script', it is not an option of 'bash': https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/script.1.html (this is in Darwin) - http://man7.org/linux/man-pages/man1/script.1.html this is in Linux... – shaice Oct 31 '16 at 11:54
  • This is the '-c' option part that is missing in the BSD version of 'script' present in Darwin.. "-c, --command command Run the command rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty." – shaice Oct 31 '16 at 11:57
  • 1
    So it have nothing to do with bash, but rater the command called `script`. Installing a newer version of bash will not make another command support more flags. – Andreas Louv Oct 31 '16 at 11:57
  • You missed completely the point: I want to install a new version of the `script` command which supports `-c` option. What has bash to do with it? – shaice Oct 31 '16 at 13:18
  • @shaice - the point is, this is not a bash question, yet you've tagged your question [tag:bash]. And it's not a programming question, so it's off-topic for StackOverflow (hence my close vote). You will likely have better luck and fewer downvotes on http://Superuser.com/ or [AskDifferent](http://apple.stackexchange.com/). – ghoti Oct 31 '16 at 16:50

1 Answers1

0

If the command script doesn't support a -c flag one can then you to add the command as stdin:

echo 'ispell text.txt' | script /dev/null

But looking at that command it seems like you are using it wrong as the output file is /dev/null.

Instead use:

bash -c 'ispell text.txt'

Or even:

ispell text.txt
Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
  • I need to pass 'yes 0' to ispell to use it non-interactively as stated here: http://stackoverflow.com/questions/12453196/spell-checking-a-file-using-command-line-non-interactively. _You need the script command because some commands like ispell doesn't want to be scripted. Normally you would pipe the output of yes 0 to a command to simulate hitting the "0" key all the time but some commands detect being scripted and refuse to cooperate_ And the command `script` **supports** `-c` but not in Darwin (I dunno why) – shaice Oct 31 '16 at 12:10