I talked with dgk and need to clear up my previous post
the ksh93 method is a bit detailed also, but the details
can be encapsulated in a function

        ifs=$IFS
        IFS=$'\n\n'
        set --noglob
        myarray=( $(<myfile) )
        set --glob
        IFS=$ifs

IFS=$'\n\n' marks $'\n' as a field delimiter instead of a space separator
this will handle empty lines
--noglob is required to turn off file name expansion

there is a bug (already fixed for the next release) that eliminates
all trailing newlines -- the fix will drop only the last trailing newline
(as is done for posix here documents)

so this will work correctly for posix text files that must, by definition,
contain a trailing newline
for non-empty files with no trailing newline it will act as if one were there
(just like sort(1))

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to