REXX……というかReginaでワンライナーの方法が分からないので、力ずくで。

これは恐らくバッドノウハウ且つマイナーネタ。

手元のWindows PCにはREXXの処理系としてReginaが入っているのだが、コマンドプロンプトからワンライナーする方法が分からない。

D:\tmp>regina -v
REXX-Regina_3.5(MT) 5.00 31 Dec 2009

D:\tmp>regina -h

Regina REXX-Regina_3.5(MT) 5.00 31 Dec 2009. All rights reserved.
Regina is distributed under the terms of the GNU Library Public License
and comes with NO WARRANTY. See the file COPYING-LIB for details.

To run a Rexx program:
regina [-h?vrt[ir]ap] program [arguments...]
where:

-h,-?                  show this message
-v                     display Regina version and exit
-r                     run Regina in "safe" mode
-t[trace_char]         set TRACE any valid TRACE character - default A
-a                     pass command line to Rexx program as separate arguments
-p                     pause after execution (Win32 only)
-l[locale]             use the system's default charset or a supplied one

To tokenise a Rexx program:
regina -c program(input) tokenisedfile(output)

To execute a tokenised file:
regina -e tokenisedfile [arguments...]

If you intend using external functions (using RxFuncAdd) you need to run the "regina" executable

D:\tmp>

ドキュメント等を見ても、それらしいオプションが無い。ということはそもそも不可能なのだろうか?

ただスクリプトファイルを何も指定せずにReginaを実行すると、標準入力からスクリプトを読み込んで実行するようだ。

D:\tmp>regina
do 10
  say 'hello, world'
end
/* ↓の ^Z は Ctrl+Z */
^Z
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world

D:\tmp>

インタラクティブではないのが残念*1だが、これを利用して無理やりワンライナーっぽい感じでReginaを使う方法に気づいた。

D:\tmp>echo do 10; say 'hello, world'; end | regina
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world
hello, world

D:\tmp>

ワンライナーした中身を、echoを使って標準入力経由でReginaに流し込むのだ。特殊文字エスケープが少々面倒*2だが、何とか動く。まあ多分、既出ネタだろう。

LinuxFreeBSDなどでも似たような方法が使えると思う……まさかWindows以外ではワンライナーのオプションがあるとか、そんなことは無いよね?

*1:rexxtryを使え? アレってWindows && Reginaでも問題なく動くものなのだろうか?

*2:面倒というか、エスケープの仕様を調べるのに苦労する。