このディレクトリの索引

shs(Command,X) :-
        popen(Command,L),
        shs_2(L,X).

shs_2([],[]) :- !.
shs_2(L,[S|R]) :-
        append(L0,['\n'|R1],L),
        atom_chars(S,L0),
        shs_2(R1,R),!.
shs_2(L,[S]) :-
        atom_chars(S,L).

popen(Command,Chars) :-
        open(pipe(Command),read,Instream),
        get_char(Instream,Char),
        popen(Instream,Char,Chars),
        close(Instream),!.

popen(Instream,end_of_file,[]) :- !.
popen(Instream,Char,[Char|R]) :-
        get_char(Instream,Char2),
        popen(Instream,Char2,R).