0

I have a shell script in which I decode an included base64 encoded string, see code below. This works fine on Linux and MacOS for encoded string sizes up to 100s MB in size. However, when using Git Bash on Windows it only works for small size encoded strings. I do not know the exact 'cutoff point' but when using larger strings it does not work anymore and the process hangs forever, with high CPU rate.

Does anybody have experience with this, or maybe a workaround? Preference is to have the encoded string included in the shell script.

Regards,

Emil

#!/bin/bash
openssl base64 -d <<MYSTOPPER > test.txt
VGhlIHBsb3QgcmV2b2x2ZXMgYXJvdW5kIHRoZSBhZHZlbnR1cmVzIG9mIGEgbm9i
bGUgKGhpZGFsZ28pIGZyb20gTGEgTWFuY2hhIG5hbWVkIEFsb25zbyBRdWl4YW5v
LCB3aG8gcmVhZHMgc28gbWFueSBjaGl2YWxyaWMgcm9tYW5jZXMgdGhhdCBoZSBs
b3NlcyBoaXMgbWluZCBhbmQgZGVjaWRlcyB0byBiZWNvbWUgYSBrbmlnaHQtZXJy
YW50IChjYWJhbGxlcm8gYW5kYW50ZSkgdG8gcmV2aXZlIGNoaXZhbHJ5IGFuZCBz
ZXJ2ZSBoaXMgbmF0aW9uLCB1bmRlciB0aGUgbmFtZSBEb24gUXVpeG90ZSBkZSBs
YSBNYW5jaGEu
MYSTOPPER
# This is the output string:
# 'The plot revolves around the adventures of a noble (hidalgo) from La Mancha named Alonso Quixano, who reads so many chivalric romances that he loses his mind and decides to become a knight-errant (caballero andante) to revive chivalry and serve his nation, under the name Don Quixote de la Mancha.'
# Works fine on MacOS and Linux for any size encoded string, fails in Git Bash on Windows with larger strings
  • 1
    Does this answer your question? [OpenSSL hangs during PKCS12 export with "Loading 'screen' into random state"](https://stackoverflow.com/questions/34156938/openssl-hangs-during-pkcs12-export-with-loading-screen-into-random-state) – Aserre Mar 23 '21 at 10:06
  • 1
    I've seen several other questions whose answer suggest the same solution, such as [this one](https://stackoverflow.com/questions/3758167/openssl-command-hangs) or [this one](https://stackoverflow.com/questions/9450120/openssl-hangs-and-does-not-exit/45732888) – Aserre Mar 23 '21 at 10:08
  • Interestings reads on the particularities of openssl on Windows and pointer to winpty, thanks for that. In the meantime I've seen that my test script with large string sometimes does finish on Windows, but only after ~15 minutes where MacOS/Linux do it in <30 seconds. Also whe. extending the script with additional commands after the MYSTOPPER line seems to give issues. Might be something with the expected keypress on Windows? So still bit of investigation todo, will also check how this behaves with Linux subsystem on Windows. – Emil Zegers Mar 24 '21 at 00:02

0 Answers0