envvars.c 641 B

123456789101112131415161718192021222324
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. int main(int argc, char **argv) {
  5. if(strcmp(getenv("first"), "val1") != 0) {
  6. fprintf(stderr, "First envvar is wrong. %s\n", getenv("first"));
  7. return 1;
  8. }
  9. if(strcmp(getenv("second"), "val2") != 0) {
  10. fprintf(stderr, "Second envvar is wrong.\n");
  11. return 1;
  12. }
  13. if(strcmp(getenv("third"), "val3:and_more") != 0) {
  14. fprintf(stderr, "Third envvar is wrong.\n");
  15. return 1;
  16. }
  17. if(strstr(getenv("PATH"), "fakepath:") != NULL) {
  18. fprintf(stderr, "Third envvar is wrong.\n");
  19. return 1;
  20. }
  21. return 0;
  22. }