Skip to content

Comment on Parsing command line arguments using a finite state machine and backtrackingparent

Comments

I thought about the same thing in regards to cp. I've been using OpenBSD a lot lately and having it's source installed wanted to take a look at their coding style and such. I picked cp as my first glance as I thought that should be simple enough to understand quickly.

As you say, it's option parsing makes up the bulk of the cp.c code, with utils.c doing most of the actual file copying. It turns out it's pretty tough to offer a lot of options with some of them being mutually exclusive. Obvious in hindsight but interesting to me at the time I was reading through it.

http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/bin/...

http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/bin/...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.