view toys/readlink.c @ 223:52a0c06b2dad

Teach readlink to actually do -f.
author Rob Landley <rob@landley.net>
date Sat, 05 Jan 2008 15:20:26 -0600
parents 30a6db5a95c2
children d4176f3f3835
line wrap: on
line source

/* vi: set sw=4 ts=4: */
/*
 * readlink.c - Return string representation of a symbolic link.
 *
 * Not in SUSv3.
 */

#include "toys.h"

void readlink_main(void)
{
	char *s;

	// Calculating full cannonical path?

	if (CFG_READLINK_F && toys.optflags) s = realpath(*toys.optargs, NULL);
	else s = xreadlink(*toys.optargs);

	if (s) {
		xputs(s);
		if (CFG_TOYBOX_FREE) free(s);
	} else toys.exitval = 1;
}