Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Accept option x or x and b
- eg: sh script -x <arg> (or) ;will execute function a defined in script
- sh script -x <arg> -b ;will execute the functions a and b
- 2. Accept option m or m and b
- eg: sh script -m <arg> (or) ;execute function c
- sh script -m <arg1> -b ;should execute function for c and b
- 3. Option both x and m should not be passed together.
- This will print usage(how to use the input options) function.
- 4. Option v. This should not be passed with any other option.
- eg: sh script -v <arg> ; executs the function for v
- while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1)
- switch (ch) {
- case 'H':
- Hflag = 1;
- Lflag = 0;
- break;
- case 'L':
- Lflag = 1;
- Hflag = 0;
- break;
- ...
- case 'l':
- lflag = 1;
- break;
- ...
- case 's':
- sflag = 1;
- break;
- case 'v':
- vflag = 1;
- break;
- case 'x':
- fts_options |= FTS_XDEV;
- break;
- default:
- usage();
- break;
- }
- if (lflag && sflag)
- errx(1, "the -l and -s options may not be specified together");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement