Difference between
modified post 81f23 by Anonymous on Fri 1st Sep 2023 11:11
original post 31d07f8 by Anonymous on Fri 1st Sep 2023 04:11
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | #!/usr/bin/ksh93 | |
| 2 | 2 | ||
| 3 | 3 | # | |
| 4 | 4 | # mkfifo - mkfifo emulation hack for Cygwin on NFS filesystems | |
| 5 | 5 | # | |
| 6 | 6 | # Simple hash full path of FIFO, create FIFO in /tmp | |
| 7 | 7 | # and use original pathname for softlink to FIFO in /tmp | |
| 8 | 8 | # | |
| 9 | 9 | # Script should be chmod +x and then in front of PATH, | |
| 10 | 10 | # before /usr/bin:/bin where the normal mkfifo resides | |
| 11 | 11 | # | |
| 12 | 12 | ||
| 13 | 13 | # | |
| 14 | 14 | # Written by Roland Mainz <roland.mainz@nrubsig.org> | |
| 15 | 15 | # | |
| 16 | 16 | ||
| 17 | 17 | function usage | |
| 18 | 18 | { | |
| 19 | 19 | OPTIND=0 | |
| 20 | 20 | getopts -a "$0" "${mkfifo_usage}" OPT '-?' | |
| 21 | 21 | exit 2 | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | 24 | typeset -r mkfifo_usage=$'+ | |
| 25 | 25 | [-?\n@(#)\$Id: mkfifo (Roland Mainz) 2023-09-01 \$\n] | |
| 26 | 26 | [-author?Roland Mainz <roland.mainz@nrubsig.org>] | |
| 27 | 27 | [+NAME?mkfifo - mkfifo emulation hack for Cygwin nfs] | |
| 28 | 28 | [+DESCRIPTION?\bshlint\b is a lint for POSIX shell scripts.] | |
| 29 | 29 | [m:mode?set file permissions.]:[number] | |
| 30 | 30 | ||
| 31 | 31 | name | |
| 32 | 32 | ||
| 33 | 33 | [+SEE ALSO?\bshcomp\b(1), \bksh93\b(1)] | |
| 34 | 34 | ' | |
| 35 | 35 | ||
| 36 | 36 | builtin getconf | |
| 37 | 37 | ||
| 38 | 38 | while getopts -a "${progname}" "${mkfifo_usage}" OPT ; do | |
| 39 | 39 | # printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|" | |
| 40 | 40 | case "${OPT}" in | |
| 41 | 41 | 'm') typeset fifomode="$OPTARG" ;; | |
| 42 | 42 | *) usage ;; | |
| 43 | 43 | esac | |
| 44 | 44 | done | |
| 45 | 45 | shift $(( OPTIND-1 )) | |
| 46 | 46 | ||
| 47 | 47 | (( $# > 0 )) || usage | |
| 48 | 48 | ||
| 49 | 49 | # reset PATH to the platform's default | |
| 50 | 50 | export PATH="$(getconf PATH)" | |
| 51 | 51 | ||
| 52 | 52 | integer retval=0 | |
| 53 | 53 | typeset fifoname | |
| 54 | 54 | typeset hash | |
| 55 | 55 | typeset dummy | |
| 56 | 56 | ||
| 57 | 57 | for fifoname in "$@" ; do | |
| 58 | 58 | realpath "$fifoname" | md5sum | read hash dummy | |
| 59 | 59 | fifopath="/tmp/nfsfifo_${hash}.fifo" | |
| 60 | 60 | rm -f "$fifopath" | |
| 61 | 61 | ||
| 62 | 62 | if [[ -v fifomode ]] ; then | |
| 63 | 63 | mkfifo -m "$fifomode" "$fifopath" | |
| 64 | 64 | (( retval=$? )) | |
| 65 | 65 | else | |
| 66 | 66 | mkfifo "$fifopath" | |
| 67 | 67 | (( retval=$? )) | |
| 68 | 68 | fi | |
| 69 | 69 | if (( retval == 0 )) ; then | |
| 70 | 70 | ln -sf "$fifopath" "$fifoname" | |
| 71 | 71 | else | |
| 72 | 72 | break | |
| 73 | 73 | fi | |
| 74 | 74 | done | |
| 75 | 75 | ||
| 76 | 76 | exit $retval | |
| 77 | 77 | #EOF. | |
| 78 | 78 |
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
rovema.kpaste.net RSS