bugGNU Octave - Bugs: bug #66829, (image) uses GNU extensions for...

 
 

bug #66829: (image) uses GNU extensions for grep

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Fri 21 Feb 2025 11:14:29 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Patch Submitted Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Release: 
Operating System:  * Mac OS Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 04 May 2025 05:03:27 AM UTC, comment #13: 

Thanks,

This fix also works for me.

The warning comes for the test:

# Support "inline" functions as long as Octave itself does (bug #59022)
%!assert (blockproc (eye (6), [2, 2], "sum"),
%!        blockproc (eye (6), [2, 2], inline ("sum (x)", "x")))

Maybe we can shut off the warning for this test only?

Avinoam Kalma <avinoam>
Group Member
Fri 02 May 2025 07:25:23 PM UTC, comment #12: 

A somewhat radical approach: let octave process PKG_ADD.
Add the attached file (file run_pkg_add.m) to the root directory.
Change Makefile:

diff -r 58c7be8946bc Makefile
--- a/Makefile  Fri May 02 07:02:11 2025 +0300
+++ b/Makefile  Fri May 02 15:13:29 2025 -0400
@@ -18,17 +18,15 @@
 M_SOURCES   := $(wildcard inst/*.m)
 CC_SOURCES  := $(wildcard src/*.cc)
 OCT_FILES   := $(patsubst %.cc,%.oct,$(CC_SOURCES))
-PKG_ADD     := `grep -sh "^// PKG_ADD: \|^## PKG_ADD: \
-                " $(CC_SOURCES) $(M_SOURCES) \
-               | sed "s/^[/][/] PKG_ADD: \|^## PKG_ADD: //"`

 #OCTAVE ?= octave --no-window-system --silent
 # remove --no-window-system in order to use "qt" graphics toolkit
 OCTAVE ?= octave --silent
 MKOCTFILE ?= mkoctfile

+PWD != pwd
 ## Command line arguments to use when calling Octave.
-PATH_ARGS = --path 'inst/' --path 'src/'
+PATH_ARGS = --path '$(PWD)/inst/' --path '$(PWD)/src/'

 .PHONY: help dist html release install all check run clean

@@ -91,12 +89,12 @@

 check: all
        $(OCTAVE) ${PATH_ARGS} \
-         --eval '${PKG_ADD}' \
+         --eval "run_pkg_add ();"\
          --eval 'oruntests ("inst"); oruntests ("src");'

 doctest: all
        $(OCTAVE) ${PATH_ARGS} \
-         --eval '${PKG_ADD}' \
+         --eval "run_pkg_add ();"\
          --eval 'pkg load doctest;' \
          --eval "targets = '$(shell (ls inst; ls src | $(GREP) .oct) | cut -f2 -d@ | cut -f1 -d.)';" \
          --eval "targets = strsplit (targets, ' ');" \
@@ -104,7 +102,7 @@

 run: all
        $(OCTAVE) --persist ${PATH_ARGS} \
-         --eval '${PKG_ADD}'
+         --eval "run_pkg_add ();"

 clean:
        $(RM) -r $(TARGET_DIR)


"make check" works for me now.
I see a warning:

blockproc.m .................................................warning: inline is obsolete; use anonymous functions instead



Dmitri.
--


(file #57188)

Dmitri A. Sergatskov <dasergatskov>
Fri 02 May 2025 07:49:27 AM UTC, comment #11: 

Re-openning this bug report, because I get on Ubuntu:


> make check
...
octave --silent --path 'inst/' --path 'src/' \
  --eval '`grep -sh "^// PKG_ADD: \|^' \
  --eval 'oruntests ("inst"); oruntests ("src");'
error: invalid character '`' (ASCII 96)

>>> `grep -sh "^// PKG_ADD: \|^ oruntests ("inst"); oruntests ("src");
    ^
make: *** [Makefile:93: check] Error 1


How to fix this?

Thanks

Avinoam Kalma <avinoam>
Group Member
Wed 05 Mar 2025 09:58:44 PM UTC, comment #10: 

closing as fixed.

Avinoam Kalma <avinoam>
Group Member
Sat 01 Mar 2025 08:28:11 PM UTC, comment #9: 
Avinoam Kalma <avinoam>
Group Member
Thu 27 Feb 2025 11:15:07 PM UTC, comment #8: 

Thanks John,

The following

PKG_ADD     := `grep -sh "^// PKG_ADD: \|^## PKG_ADD: " $(CC_SOURCES) $(M_SOURCES) \
                                       | sed "s/^[/][/] PKG_ADD: \|^## PKG_ADD: //"`


seems to be working for me for both gmake and make.
Somebody has o verify that it still does what it supposed to be doing.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 27 Feb 2025 06:17:00 PM UTC, comment #7: 

I believe the Old Way of doing this is to use backquotes around the command:


VAR := `grep -opts ...`


John W. Eaton <jwe>
Group administrator
Thu 27 Feb 2025 05:17:02 PM UTC, comment #6: 

This

diff -r 0dfa908ad794 Makefile
--- a/Makefile  Thu Feb 27 15:46:32 2025 +0000
+++ b/Makefile  Thu Feb 27 12:14:20 2025 -0500
@@ -18,9 +18,7 @@
 M_SOURCES   := $(wildcard inst/*.m)
 CC_SOURCES  := $(wildcard src/*.cc)
 OCT_FILES   := $(patsubst %.cc,%.oct,$(CC_SOURCES))
-PKG_ADD     := $(shell grep -sh '^\(//\|##\) PKG_ADD: ' \
-                            $(CC_SOURCES) $(M_SOURCES) \
-                       | sed 's,^\(//\|##\) PKG_ADD: ,,')
+PKG_ADD != grep -sh "^// PKG_ADD: \|^## PKG_ADD: " $(CC_SOURCES) $(M_SOURCES) | sed "s/^[/][/] PKG_ADD: \|^## PKG_ADD: // "


works for BSD make, but not for GNU make:

 % gmake clean
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file


Life is hard.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 27 Feb 2025 03:57:02 PM UTC, comment #5: 

Somewhat off-topic.
May be you can fix Makefile too?

% make clean
Makefile:21: *** unterminated call to function `shell': missing `)'.  Stop.


(Works with gmake).

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 27 Feb 2025 03:49:54 PM UTC, comment #4: 

I have just pushed 0dfa908ad794 which replaces the use of `grep -Po` (PCRE was used for the zero-width look behind) with grep and sed. This no longer needs a special grep so users don't need to specify the GREP variable.

Carnë Draug <carandraug>
Group Member
Wed 26 Feb 2025 10:48:08 PM UTC, comment #3: 
Avinoam Kalma <avinoam>
Group Member
Mon 24 Feb 2025 10:19:13 PM UTC, comment #2: 

Thanks. I revert my change

Avinoam Kalma <avinoam>
Group Member
Mon 24 Feb 2025 10:16:44 PM UTC, comment #1: 

As of:
https://wiki.octave.org/Online_Developer_Meeting_(2024-03-26)


New bug reports on Savannah for packages should be tagged by the package name in parenthesis at the start of the report title. E.g., "(statistics) some error" (i.e., no longer prepend with "[octave forge]"). Also, set the report category to "Octave package". Try to CC package developers.


FYI.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 21 Feb 2025 11:14:29 PM UTC, original submission:  

A line in the make file:

PKG_ADD     := $(shell grep -sPho '(?<=(//|\#\#) PKG_ADD: ).*' $(CC_SOURCES) $(M_SOURCES))

cause an error on MacOS (and presumably on some other non-GNU OSes). Parameter "-P" is a GNU extension and does not work with

% grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD


One way to fix it is to rely on $GREP var like that:

% hg diff
diff -r 4fedd61e2853 Makefile
--- a/Makefile  Fri Feb 21 12:08:49 2025 +0200
+++ b/Makefile  Fri Feb 21 18:05:35 2025 -0500
@@ -6,8 +6,10 @@
 ## notice and this notice are preserved.  This file is offered as-is,
 ## without any warranty.

-PACKAGE := $(shell grep "^Name: " DESCRIPTION | cut -f2 -d" ")
-VERSION := $(shell grep "^Version: " DESCRIPTION | cut -f2 -d" ")
+GREP ?= grep
+
+PACKAGE := $(shell $(GREP) "^Name: " DESCRIPTION | cut -f2 -d" ")
+VERSION := $(shell $(GREP) "^Version: " DESCRIPTION | cut -f2 -d" ")

 TARGET_DIR      := target
 RELEASE_DIR     := $(TARGET_DIR)/$(PACKAGE)-$(VERSION)
@@ -18,7 +20,7 @@
 M_SOURCES   := $(wildcard inst/*.m)
 CC_SOURCES  := $(wildcard src/*.cc)
 OCT_FILES   := $(patsubst %.cc,%.oct,$(CC_SOURCES))
-PKG_ADD     := $(shell grep -sPho '(?<=(//|\#\#) PKG_ADD: ).*' $(CC_SOURCES) $(M_SOURCES))
+PKG_ADD     := $(shell $(GREP) -sPho '(?<=(//|\#\#) PKG_ADD: ).*' $(CC_SOURCES) $(M_SOURCES))

 #OCTAVE ?= octave --no-window-system --silent
 # remove --no-window-system in order to use "qt" graphics toolkit
@@ -96,7 +98,7 @@
        $(OCTAVE) ${PATH_ARGS} \
          --eval '${PKG_ADD}' \
          --eval 'pkg load doctest;' \
-         --eval "targets = '$(shell (ls inst; ls src | grep .oct) | cut -f2 -d@ | cut -f1 -d.)';" \
+         --eval "targets = '$(shell (ls inst; ls src | $(GREP) .oct) | cut -f2 -d@ | cut -f1 -d.)';" \
          --eval "targets = strsplit (targets, ' ');" \
          --eval "doctest (targets);"

(so people can do e.g. "GREP=ggrep make dist" to cal a GNU version of grep ("ggrep" on my system).

Or just re-write the offending line so it does not use "-P" parameter.

Dmitri.
--
 


Dmitri A. Sergatskov <dasergatskov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #57188:  run_pkg_add.m added by dasergatskov (3KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by avinoam (Updated the item)
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-14 avinoam StatusIn Progress Patch Submitted
    2025-05-02 dasergatskov Attached File- Added run_pkg_add.m, #57188
    2025-05-02 avinoam StatusFixed In Progress
        Open/ClosedClosed Open
    2025-03-05 avinoam StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2025-02-28 avinoam StatusFixed In Progress
        Open/ClosedClosed Open
    2025-02-26 avinoam StatusNone Fixed
        Open/ClosedOpen Closed
    2025-02-24 avinoam Summary[octave forge] (image) uses GNU extensions for grep (image) uses GNU extensions for grep
    2025-02-24 avinoam Summary(image) uses GNU extensions for grep [octave forge] (image) uses GNU extensions for grep
        Carbon-Copy- Added hardy
        Carbon-Copy- Added carandraug

    Back to the top

    Powered by Savane 3.15-f85b.
    Corresponding source code