Project

General

Profile

Actions

Bug #10700

closed

bzgrep has bashisms

Added by Predrag Zečević over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
OI-Userland
Target version:
Start date:
2019-04-08
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

Hi all,

bzgrep throws error:

"s|^|\&\\&|\&m\&\\&|\&a\ ...": 1: bad flag in substitute command: '\'

Most likely because it uses /bin/sh as shell (which works well on linux, but not in OI):
==> /usr/bin/bzcmp <==
#!/bin/sh

==> /usr/bin/bzdiff <==
#!/bin/sh

==> /usr/bin/bzegrep <==
#!/bin/bash

==> /usr/bin/bzfgrep <==
#!/bin/bash

==> /usr/bin/bzgrep <==
#!/bin/sh

As we see, some already have /bin/bash , so I guess all of then missing it have to be fixed.

Regards.

P.S: If I substitute /bin/sh with /bin/bash in bzgrep utility, it "works" fine.

Actions #1

Updated by Predrag Zečević over 4 years ago

Forgot 2 more:

==> /usr/bin/bzless <==
#!/bin/sh

==> /usr/bin/bzmore <==
#!/bin/sh

Actually, only few files need fix, because:

:; file /usr/bin/bzcmp
/usr/bin/bzcmp: symbolic link to ./bzdiff
:; file /usr/bin/bzdiff
/usr/bin/bzdiff: Bourne-Again shell script, ASCII text executable
:; file /usr/bin/bzless
/usr/bin/bzless: symbolic link to ./bzmore
:; file /usr/bin/bzmore
/usr/bin/bzmore: Bourne-Again shell script, ASCII text executable

Actions #2

Updated by Alexander Pyhalov over 4 years ago

Do you have a reproducer? I don't see this error in simple cases.

Actions #3

Updated by Michal Nowak over 4 years ago

  • Status changed from New to Feedback

We can't do anything, Predrag, unless we have a reproducer. I don't see it on my system.

Actions #4

Updated by Michal Nowak over 4 years ago

  • Status changed from Feedback to Rejected
  • Tags deleted (needs-triage)

We can't do much without user responses.

Actions #5

Updated by Predrag Zečević over 4 years ago

Right now:

:; uname -rosv
SunOS 5.11 illumos-8abca89f41 illumos

Fixed package (maybe I have changed something):

:; pfexec pkg fix compress/bzip2
               Packages to fix:   1
       Create boot environment:  No
Create backup boot environment: Yes

Repairing: pkg://openindiana.org/compress/bzip2@1.0.6,5.11-2018.0.0.5:20190311T115616Z
PACKAGE                                                                 STATUS
pkg://openindiana.org/compress/bzip2                                     ERROR
        file: usr/bin/bzdiff
                ERROR: Size: 2130 bytes should be 2128
                ERROR: Hash: 112715af92d067bdd8ec551eb720faccff0e6336 should be b18f2c881197ae12beeea03f26b85ce3ec875a42
        file: usr/bin/bzgrep
                ERROR: Size: 1679 bytes should be 1677
                ERROR: Hash: f73f69254632e0b1ea6d7d936cafe3322029dd69 should be 500ea98094773c3ac10a76009c34f194c9ff2aea
        file: usr/bin/bzmore
                ERROR: Size: 1261 bytes should be 1259
                ERROR: Hash: be3a591a6be558802e130c17089a15a5e449c1bf should be 565f7e9a4db0aa84738983ed1172dfd0e5d294cc
DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                                1/1           3/3      0.0/0.0  1.2k/s

PHASE                                          ITEMS
Updating modified actions                        3/3
Updating package state database                 Done 
Updating package cache                           0/0 
Updating image state                            Done 
Creating fast lookup database                   Done 
Updating package cache                           3/3 

Still wrong:

:; head -1 /usr/bin/bzdiff /usr/bin/bzgrep /usr/bin/bzmore
==> /usr/bin/bzdiff <==
#!/bin/sh

==> /usr/bin/bzgrep <==
#!/bin/sh

==> /usr/bin/bzmore <==
#!/bin/sh

Version:
:; pkg info bzip2
          Name: compress/bzip2
       Summary: high-quality block-sorting file compressor - utilities
   Description: bzip2 is a freely available, patent free, high-quality data
                compressor.
      Category: Applications/System Utilities
         State: Installed
     Publisher: openindiana.org
       Version: 1.0.6
        Branch: 2018.0.0.5
Packaging Date: Mon Mar 11 11:56:16 2019
          Size: 393.79 kB
          FMRI: pkg://openindiana.org/compress/bzip2@1.0.6-2018.0.0.5:20190311T115616Z
   Project URL: https://sourceware.org/bzip2/
    Source URL: https://sourceforge.net/projects/bzip2/files/bzip2-1.0.6.tar.gz


It will fail again...

Regards!

Actions #6

Updated by Predrag Zečević over 4 years ago

It looks like bzgrep fails only when grepping through more files:
No error:

:; bzgrep pattern filename

Error: "s|^|\&\\&|\&/\&\\&|\&e\ ...": 1: bad flag in substitute command: '\' when
:; bzgrep pattern file*

Regards

Actions #7

Updated by Michal Nowak over 4 years ago

  • Category set to OI-Userland
  • Status changed from Rejected to Feedback
  • Assignee set to Michal Nowak
  • Target version set to Hipster
  • % Done changed from 0 to 50

Thanks for the info, Predrag. I think you are right, there "bashisms" in the bzgrep script:

$ ./scripts/checkbashisms.pl /usr/bin/bzgrep 
possible bashism in /usr/bin/bzgrep line 66 (${parm/?/pat[/str]}):
    j=${i//\\/\\\\}
possible bashism in /usr/bin/bzgrep line 67 (${parm/?/pat[/str]}):
    j=${j//|/\\|}
possible bashism in /usr/bin/bzgrep line 68 (${parm/?/pat[/str]}):
    j=${j//&/\\&}

This patch works for me: https://build.opensuse.org/package/view_file/Archiving/bzip2/bzip2-1.0.6-fix-bashisms.patch?expand=1. Do you mind trying it as well?

Actions #8

Updated by Michal Nowak over 4 years ago

  • Subject changed from bzip2: shell utilities and /bin/sh to bzgrep has bashisms
  • Status changed from Feedback to In Progress
Actions #9

Updated by Michal Nowak over 4 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 50 to 100

Predrag, if you can test, have a look at https://github.com/OpenIndiana/oi-userland/pull/5028, otherwise should be merged in few days.

Actions

Also available in: Atom PDF