Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. 1. Accept option x or x and b
  2. eg: sh script -x <arg> (or) ;will execute function a defined in script
  3. sh script -x <arg> -b ;will execute the functions a and b
  4.  
  5. 2. Accept option m or m and b
  6. eg: sh script -m <arg> (or) ;execute function c
  7. sh script -m <arg1> -b ;should execute function for c and b
  8.  
  9. 3. Option both x and m should not be passed together.
  10. This will print usage(how to use the input options) function.
  11.  
  12. 4. Option v. This should not be passed with any other option.
  13. eg: sh script -v <arg> ; executs the function for v
  14.  
  15. while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1)
  16. switch (ch) {
  17. case 'H':
  18. Hflag = 1;
  19. Lflag = 0;
  20. break;
  21. case 'L':
  22. Lflag = 1;
  23. Hflag = 0;
  24. break;
  25. ...
  26. case 'l':
  27. lflag = 1;
  28. break;
  29. ...
  30. case 's':
  31. sflag = 1;
  32. break;
  33. case 'v':
  34. vflag = 1;
  35. break;
  36. case 'x':
  37. fts_options |= FTS_XDEV;
  38. break;
  39. default:
  40. usage();
  41. break;
  42. }
  43.  
  44. if (lflag && sflag)
  45. errx(1, "the -l and -s options may not be specified together");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement