pastebin - collaborative debugging tool
rovema.kpaste.net RSS


Cygwin mkfifo.nfs hack
Posted by Anonymous on Fri 1st Sep 2023 11:11
raw | new post
modification of post by Anonymous (view diff)

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

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at