
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#define NAME  "node"

#define WRAP  PREFIX "/bin/" NAME
#define REAL  PREFIX "/libexec/" NAME "/node"

int main(int argn, char **argv)
{
    char *path;

    argv[0] = REAL;
    if ((path = getenv("NODE")) != NULL)
        if (strcmp(path, NAME) != 0 && strcmp(path, WRAP) != 0)
            argv[0] = path;

    if (execvp(argv[0], argv) == -1) {
        fprintf(stderr, "node: ERROR: failed to execute \"%s\": %s\n", argv[0], strerror(errno));
        exit(1);
    }

    return 0;
}

