From fad7e8594837652d6bc34e0a19070e4ffc5d11fd Mon Sep 17 00:00:00 2001 From: Kevin Pulo Date: Thu, 15 Jan 2015 15:12:56 +1100 Subject: [PATCH] mdiag.sh: tolerate being in DOS format (CR/LFs) For example, this can come about if the script is downloaded in a browser in Windows, and then transferred (in binary mode) to the Linux host. --- mdiag/mdiag.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mdiag/mdiag.sh b/mdiag/mdiag.sh index 7d1a8dfc..22d8c11b 100644 --- a/mdiag/mdiag.sh +++ b/mdiag/mdiag.sh @@ -1,4 +1,7 @@ #!/bin/bash +# The following 2 lines make "bash mdiag.sh ..." work even if the file is in DOS format (with CR/LFs). +eval "`echo -ne '\r'`() { sed 's/\x0D$//' '$0' | '$BASH' -s -- "'"${a[@]}" ; exit $?; }'; a=("$@"); +unset a # =================================== # mdiag.sh: MongoDB Diagnostic Report