[Toybox] ls implementation

Andre Renaud andre at bluewatersys.com
Tue Feb 14 12:15:19 PST 2012


Hi Rob,

>> I've added a couple of bits to it, so that it supports ls -lFa1. The
>> main thing missing is support for files in the command line (currently
>> it only supports directories).
> 
> And -R support.

Attached is a patch that adds support for having files on the command
line (as well as directories), and -R support. There are two drawbacks
to it however:

The files on the command line always get treated as separate items, so
they always appear one per line, even if -1 hasn't been specified.

To support -R I've done the trivial recursive implementation, but
because I need a string for the next directory name, it has pretty
massive stack usage (PATH_MAX * depth).

Both of these issues would be resolved by maintaining some kind of
growing list of entries to be written to, which could be re-purposed as
they're printed, however the structure I implemented initially doesn't
extend to that trivially.

For now, I think this is relatively usable & simple, if not particularly
optimal.

Regards,
Andre

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ls.diff
Type: text/x-patch
Size: 3181 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20120215/c0888723/attachment-0007.bin>


More information about the Toybox mailing list