Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash error since openssl updates #1324

Open
3 tasks done
miken32 opened this issue Feb 2, 2025 · 4 comments · May be fixed by #1327
Open
3 tasks done

Bash error since openssl updates #1324

miken32 opened this issue Feb 2, 2025 · 4 comments · May be fixed by #1327

Comments

@miken32
Copy link

miken32 commented Feb 2, 2025

Describe the bug

Since I updated from 2.14 to 2.16 I've had this error when autocompleting openssl:

-bash: command substitution: line 1: unexpected EOF while looking for matching `''

This appears to be related to PR #1256.

In addition, output from openssl ⇥⇥ looks misformatted:

mike ~ ❱❱❱ openssl -bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 1: unexpected EOF while looking for matching `''

(see                                                                      help:
Digest                                                                    idea              idea-cbc          idea-cfb          idea-ecb          
Message                                                                   idea-ofb          rc2               rc2-40-cbc        rc2-64-cbc        
Standard                                                                  info
aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb         kdf
aes-256-cbc       aes-256-ecb       aria-128-cbc      aria-128-cfb        list
aria-128-cfb1     aria-128-cfb8     aria-128-ctr      aria-128-ecb        mac
aria-128-ofb      aria-192-cbc      aria-192-cfb      aria-192-cfb1       nseq
aria-192-cfb8     aria-192-ctr      aria-192-ecb      aria-192-ofb        ocsp
aria-256-cbc      aria-256-cfb      aria-256-cfb1     aria-256-cfb8       passwd
aria-256-ctr      aria-256-ecb      aria-256-ofb      base64              pkcs12
asn1parse                                                                 pkcs7
bf                bf-cbc            bf-cfb            bf-ecb              pkcs8
bf-ofb            camellia-128-cbc  camellia-128-ecb  camellia-192-cbc    pkey
ca                                                                        pkeyparam
camellia-192-ecb  camellia-256-cbc  camellia-256-ecb  cast                pkeyutl
cast-cbc          cast5-cbc         cast5-cfb         cast5-ecb           prime
cast5-ofb         des               des-cbc           des-cfb             rand
ciphers                                                                   rc2-cbc           rc2-cfb           rc2-ecb           rc2-ofb           
cmp                                                                       rc4               rc4-40            seed              seed-cbc          
cms                                                                       rehash
commands                                                                  req
crl                                                                       rsa
crl2pkcs7                                                                 rsautl
des-ecb           des-ede           des-ede-cbc       des-ede-cfb         s_client
des-ede-ofb       des-ede3          des-ede3-cbc      des-ede3-cfb        s_server
des-ede3-ofb      des-ofb           des3              desx                s_time
dgst                                                                      seed-cfb          seed-ecb          seed-ofb          sm4-cbc           
dhparam                                                                   sess_id
dsa                                                                       sm4-cfb           sm4-ctr           sm4-ecb           sm4-ofb           
dsaparam                                                                  smime
ec                                                                        speed
ecparam                                                                   spkac
enc                                                                       srp
enc command for more details)                                             storeutl
engine                                                                    the
errstr                                                                    ts
fipsinstall                                                               verify
gendsa                                                                    version
genpkey                                                                   x509
genrsa                                                                    zlib              
help                                                                      
mike ~ ❱❱❱ openssl 

To reproduce

Tab complete openssl

Expected behavior

Versions (please complete the following information)

  • Operating system name/distribution and version: macOS 14.6, MacPorts
  • bash version, echo "$BASH_VERSION": 5.2.37(1)-release
  • bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"): 2.16.0

Additional context

OpenSSL 3.4.0 22 Oct 2024 (Library: OpenSSL 3.4.0 22 Oct 2024)

Output from openssl version was compared with a GNU/Linux system running OpenSSL 3.2.2 4 Jun 2024 (Library: OpenSSL 3.2.2 4 Jun 2024) and the output appears to be formatted identically.

Also tried running from a clean shell (bash -c bash) with the same results.

Debug trace

Full output of openssl x5⇥ (preceded by set -x) is here: https://pastebin.com/CR43uWJe

@yedayak
Copy link
Collaborator

yedayak commented Feb 2, 2025

What version is sed on your machine? sed --version
What does this print when you run it?

openssl help 2>&1 | command sed -e '/commands\|help:/d'

@miken32
Copy link
Author

miken32 commented Feb 2, 2025

@yedayak sed is the BSD version that comes with macOS, not GNU. Not sure how to get a version out of it lol

mike ~ ❱❱❱ openssl help 2>&1 | command sed -e '/commands|help:/d'
help:

Standard commands
asn1parse         ca                ciphers           cmp               
cms               crl               crl2pkcs7         dgst              
dhparam           dsa               dsaparam          ec                
ecparam           enc               engine            errstr            
fipsinstall       gendsa            genpkey           genrsa            
help              info              kdf               list              
mac               nseq              ocsp              passwd            
pkcs12            pkcs7             pkcs8             pkey              
pkeyparam         pkeyutl           prime             rand              
rehash            req               rsa               rsautl            
s_client          s_server          s_time            sess_id           
smime             speed             spkac             srp               
storeutl          ts                verify            version           
x509              

Message Digest commands (see the `dgst' command for more details)
blake2b512        blake2s256        md4               md5               
mdc2              rmd160            sha1              sha224            
sha256            sha3-224          sha3-256          sha3-384          
sha3-512          sha384            sha512            sha512-224        
sha512-256        shake128          shake256          sm3               

Cipher commands (see the `enc' command for more details)
aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb       
aes-256-cbc       aes-256-ecb       aria-128-cbc      aria-128-cfb      
aria-128-cfb1     aria-128-cfb8     aria-128-ctr      aria-128-ecb      
aria-128-ofb      aria-192-cbc      aria-192-cfb      aria-192-cfb1     
aria-192-cfb8     aria-192-ctr      aria-192-ecb      aria-192-ofb      
aria-256-cbc      aria-256-cfb      aria-256-cfb1     aria-256-cfb8     
aria-256-ctr      aria-256-ecb      aria-256-ofb      base64            
bf                bf-cbc            bf-cfb            bf-ecb            
bf-ofb            camellia-128-cbc  camellia-128-ecb  camellia-192-cbc  
camellia-192-ecb  camellia-256-cbc  camellia-256-ecb  cast              
cast-cbc          cast5-cbc         cast5-cfb         cast5-ecb         
cast5-ofb         des               des-cbc           des-cfb           
des-ecb           des-ede           des-ede-cbc       des-ede-cfb       
des-ede-ofb       des-ede3          des-ede3-cbc      des-ede3-cfb      
des-ede3-ofb      des-ofb           des3              desx              
idea              idea-cbc          idea-cfb          idea-ecb          
idea-ofb          rc2               rc2-40-cbc        rc2-64-cbc        
rc2-cbc           rc2-cfb           rc2-ecb           rc2-ofb           
rc4               rc4-40            seed              seed-cbc          
seed-cfb          seed-ecb          seed-ofb          sm4-cbc           
sm4-cfb           sm4-ctr           sm4-ecb           sm4-ofb           
zlib              

I suspect openssl help 2>&1 | command sed -E '/commands|help:/d' is what is needed; this seems to work the same with both BSD and GNU sed:

mike ~ ❱❱❱ openssl help 2>&1 | command gsed -E '/commands|help:/d'

asn1parse         ca                ciphers           cmp               
cms               crl               crl2pkcs7         dgst              
dhparam           dsa               dsaparam          ec                
ecparam           enc               engine            errstr            
fipsinstall       gendsa            genpkey           genrsa            
help              info              kdf               list              
mac               nseq              ocsp              passwd            
pkcs12            pkcs7             pkcs8             pkey              
pkeyparam         pkeyutl           prime             rand              
rehash            req               rsa               rsautl            
s_client          s_server          s_time            sess_id           
smime             speed             spkac             srp               
storeutl          ts                verify            version           
x509              

blake2b512        blake2s256        md4               md5               
mdc2              rmd160            sha1              sha224            
sha256            sha3-224          sha3-256          sha3-384          
sha3-512          sha384            sha512            sha512-224        
sha512-256        shake128          shake256          sm3               

aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb       
aes-256-cbc       aes-256-ecb       aria-128-cbc      aria-128-cfb      
aria-128-cfb1     aria-128-cfb8     aria-128-ctr      aria-128-ecb      
aria-128-ofb      aria-192-cbc      aria-192-cfb      aria-192-cfb1     
aria-192-cfb8     aria-192-ctr      aria-192-ecb      aria-192-ofb      
aria-256-cbc      aria-256-cfb      aria-256-cfb1     aria-256-cfb8     
aria-256-ctr      aria-256-ecb      aria-256-ofb      base64            
bf                bf-cbc            bf-cfb            bf-ecb            
bf-ofb            camellia-128-cbc  camellia-128-ecb  camellia-192-cbc  
camellia-192-ecb  camellia-256-cbc  camellia-256-ecb  cast              
cast-cbc          cast5-cbc         cast5-cfb         cast5-ecb         
cast5-ofb         des               des-cbc           des-cfb           
des-ecb           des-ede           des-ede-cbc       des-ede-cfb       
des-ede-ofb       des-ede3          des-ede3-cbc      des-ede3-cfb      
des-ede3-ofb      des-ofb           des3              desx              
idea              idea-cbc          idea-cfb          idea-ecb          
idea-ofb          rc2               rc2-40-cbc        rc2-64-cbc        
rc2-cbc           rc2-cfb           rc2-ecb           rc2-ofb           
rc4               rc4-40            seed              seed-cbc          
seed-cfb          seed-ecb          seed-ofb          sm4-cbc           
sm4-cfb           sm4-ctr           sm4-ecb           sm4-ofb           
zlib              

@miken32
Copy link
Author

miken32 commented Feb 2, 2025

Actually, openssl list -commands is probably what is really needed here.

@miken32
Copy link
Author

miken32 commented Feb 2, 2025

You can also append the outputs from openssl list -cipher-commands and openssl list -digest-commands if you want to get the same list as openssl help. But both categories of command are marked as deprecated so can probably be excluded safely.

yedayak added a commit to yedayak/bash-completion that referenced this issue Feb 5, 2025
In scop#1256 we started parsing
the help output. Get the list instead from the `openssl list -commands`
command.

This also stops completing the encryption and digest algorithms, since
those are usually used with the `enc` and `dgst` subcommands.

Suggested-By: Michael Newton
Fixes: scop#1324
yedayak added a commit to yedayak/bash-completion that referenced this issue Feb 5, 2025
In scop#1256 we started parsing
the help output. Get the list instead from the `openssl list -commands`
command.

This also stops completing the encryption and digest algorithms, since
those are usually used with the `enc` and `dgst` subcommands.

Suggested-By: Michael Newton
Fixes: scop#1324
@yedayak yedayak removed the need info label Feb 7, 2025
yedayak added a commit to yedayak/bash-completion that referenced this issue Feb 8, 2025
This makes this work on the BSD sed version that comes with macos.
See scop#1324
yedayak added a commit to yedayak/bash-completion that referenced this issue Feb 11, 2025
We used to also complete digest and encryption algorithms as top level
commands, but they can all be used by the `dgst` and `enc` commands.

This also makes this work on the BSD sed version that comes with macos.
See scop#1324

fix(openssl): Make command extraction from help portable for BSD sed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants