diff --git a/bin/detect b/bin/detect index 1f0d7a0..9308bfd 100644 --- a/bin/detect +++ b/bin/detect @@ -1,7 +1,7 @@ #!/usr/bin/env bash # bin/detect -if [[ -f $1/Makefile || -f $1/configure ]]; then +if [[ -f $1/Makefile ]]; then echo "C" && exit 0 else echo "no" && exit 1 diff --git a/src/server.c b/src/server.c index 8a0c475..58c3a27 100644 --- a/src/server.c +++ b/src/server.c @@ -67,14 +67,20 @@ int main(int argc, char *argv[]) struct sockaddr_storage cli_addr; char s[INET6_ADDRSTRLEN]; - if (argc != 2) + char *port; + + if (argc == 2) + port = argv[1]; + else + port = getenv("PORT"); + + if (port == NULL) { - err_msg("Usage: \n"); + perror("Port must be specified either as an argument or environment variable \"PORT\""); exit(1); } - char *port = argv[1]; - int listenfd = get_listener_socket(port); + int listenfd = get_listener_socket(port); if (listenfd < 0) { err_msg("!fatal! couldn't create listening socket");