Skip to content

Instantly share code, notes, and snippets.

@daimatz
Last active December 10, 2015 10:09
Show Gist options
  • Save daimatz/4419230 to your computer and use it in GitHub Desktop.
Save daimatz/4419230 to your computer and use it in GitHub Desktop.
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if (argc != 2) {
printf("usage: %s <path>\n", argv[0]);
exit(1);
}
char resolved_path[MAXPATHLEN];
if (realpath(argv[1], resolved_path) == NULL) {
perror("realpath failed");
exit(1);
}
printf("%s\n", resolved_path);
return 0;
}
# exec:
# curl -L https://gist.github.com/daimatz/4419230/raw/realpath.sh | bash
cd /tmp
curl -LO https://gist.github.com/raw/4419230/realpath.c
gcc -O2 -o realpath realpath.c
mkdir -p $HOME/local/bin
install -m0755 realpath $HOME/local/bin
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment