10f66f451Sopenharmony_ci/* realpath.c - Return the canonical version of a pathname
20f66f451Sopenharmony_ci *
30f66f451Sopenharmony_ci * Copyright 2012 Andre Renaud <andre@bluewatersys.com>
40f66f451Sopenharmony_ci
50f66f451Sopenharmony_ciUSE_REALPATH(NEWTOY(realpath, "<1", TOYFLAG_USR|TOYFLAG_BIN))
60f66f451Sopenharmony_ci
70f66f451Sopenharmony_ciconfig REALPATH
80f66f451Sopenharmony_ci  bool "realpath"
90f66f451Sopenharmony_ci  default y
100f66f451Sopenharmony_ci  help
110f66f451Sopenharmony_ci    usage: realpath FILE...
120f66f451Sopenharmony_ci
130f66f451Sopenharmony_ci    Display the canonical absolute pathname
140f66f451Sopenharmony_ci*/
150f66f451Sopenharmony_ci
160f66f451Sopenharmony_ci#include "toys.h"
170f66f451Sopenharmony_ci
180f66f451Sopenharmony_civoid realpath_main(void)
190f66f451Sopenharmony_ci{
200f66f451Sopenharmony_ci  char **s = toys.optargs;
210f66f451Sopenharmony_ci
220f66f451Sopenharmony_ci  for (s = toys.optargs; *s; s++) {
230f66f451Sopenharmony_ci    if (!realpath(*s, toybuf)) perror_msg_raw(*s);
240f66f451Sopenharmony_ci    else xputs(toybuf);
250f66f451Sopenharmony_ci  }
260f66f451Sopenharmony_ci}
27