How to run SWI-Prolog from the command line?

ISO directive: initialization. This should work. :- initialization main. main :- write(‘Hello World\n’). edit sorry, I skipped over most interesting details. Here is a sample script, let’s say saved in ~/test/main.pl #!/home/carlo/bin/swipl -f -q :- initialization main. main :- current_prolog_flag(argv, Argv), format(‘Hello World, argv:~w\n’, [Argv]), halt(0). and made executable with chmod +x ~/test/main.pl then I … Read more

How to run commands via NodeJS child process?

Sending a newline \n will exectue the command. .end() will exit the shell. I modified the example to work with bash as I’m on osx. var terminal = require(‘child_process’).spawn(‘bash’); terminal.stdout.on(‘data’, function (data) { console.log(‘stdout: ‘ + data); }); terminal.on(‘exit’, function (code) { console.log(‘child process exited with code ‘ + code); }); setTimeout(function() { console.log(‘Sending stdin … Read more

${BASH_SOURCE[0]} equivalent in zsh?

${BASH_SOURCE[0]} equivalent in zsh is ${(%):-%N}, NOT $0(as OP said, the latter failed in .zshrc) Here % indicates prompt expansion on the value, %N indicates “The name of the script, sourced file, or shell function that zsh is currently executing, whichever was started most recently. If there is none, this is equivalent to the parameter … Read more