Ben Hutchings <ben at decadent.org.uk> wrote:> On Sat, 2020-07-25 at 10:59 +0200, Olliver Schinagl wrote: >> Currently, in the entire klibc bash is only used to identify the path of >> the perl binary. It is doing so using the bash built-in 'type' function, >> which is POSIX compliant according to [0], but the option -c is not. >> >> By using `command -v` instead, we achieve the same result, in a POSIX >> compliant manor [1], potentially removing the unneeded bash dependency. >> >> 0 https://www.unix.com/man-page/posix/1p/type/ >> 1 https://www.unix.com/man-page/posix/1p/command/ >> >> Signed-off-by: Olliver Schinagl <oliver at schinagl.nl> > > Applied, thanks. > > Ben. > >> --- >> klcc/Kbuild | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/klcc/Kbuild b/klcc/Kbuild >> index eae753ff..0e625802 100644 >> --- a/klcc/Kbuild >> +++ b/klcc/Kbuild >> @@ -35,7 +35,7 @@ targets := $(KLIBCCROSS)klcc >> quiet_cmd_klcc = GEN $@ >> cmd_klcc = $(PERL) $< $(srctree)/$(src)/klcc.in \ >> $(obj)/$(KLIBCCROSS)klibc.config \ >> - $(shell bash -c 'type -p $(PERL)') \ >> + $(shell command -v $(PERL)) \ >> > $@ || ( rm -f $@ ; exit 1 ) && \ >> chmod a+x $@ >> $(obj)/$(KLIBCCROSS)klcc: $(src)/makeklcc.pl $(src)/klcc.in \This doesn't work with older versions of make. ?make 4.2.1 seems common now and does not support $(shell command). $ cat Makefile $(info take1: $(shell command -v ls)) $(info take2: $(shell bash -c 'type -p ls')) all: @true $ make-3.81/make make: command: Command not found take1: take2: /bin/ls $ make-4.2.1/make make: command: Command not found take1: take2: /bin/ls $ make-4.3/make take1: /bin/ls take2: /bin/ls https://git.savannah.gnu.org/cgit/make.git/commit/?id=1af314465e5dfe3e8baa839a32a72e83c04f26ef looks to be required and is in make 4.2.90+. The kernel went with https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=913ab9780fc021298949cc5514d6255a008e69f9 So we might want: $(shell command -v $(PERL) 2> /dev/null)
Greg Thelen dixit:>This doesn't work with older versions of make. ?make 4.2.1 seems common >now and does not support $(shell command). > >$ cat Makefile >$(info take1: $(shell command -v ls)) >$(info take2: $(shell bash -c 'type -p ls')) > >all: > @true > >$ make-3.81/make >make: command: Command not foundEh, what? ? checks with gmake 3.81? indeed. But no, this isn?t correct. You just do this instead: $(info take1: $(shell sh -c 'command -v ls')) This works and avoids GNU bash just the same. (I ran this on a system with no GNU bash installed.) bye, //mirabilos, shell maintainer/developer -- FWIW, I'm quite impressed with mksh interactively. I thought it was much *much* more bare bones. But it turns out it beats the living hell out of ksh93 in that respect. I'd even consider it for my daily use if I hadn't wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh
Hey Greg, On 08-09-2020 22:07, Thorsten Glaser wrote:> Greg Thelen dixit: > >> This doesn't work with older versions of make. ?make 4.2.1 seems common >> now and does not support $(shell command). >> >> $ cat Makefile >> $(info take1: $(shell command -v ls)) >> $(info take2: $(shell bash -c 'type -p ls')) >> >> all: >> @true >> >> $ make-3.81/make >> make: command: Command not found > > Eh, what?well command can be either a shell built-in or an external program, right? but both are posix required [0]? So that's a bit odd, also, wouldn't shell sh do a double shell? Shell inseption? I'm not super familiar with make though, especially ancient ones :p [0] https://www.unix.com/man-page/posix/1p/command> > ? checks with gmake 3.81? indeed. > > But no, this isn?t correct. You just do this instead: > > $(info take1: $(shell sh -c 'command -v ls')) > > This works and avoids GNU bash just the same. (I ran this > on a system with no GNU bash installed.) > > bye, > //mirabilos, shell maintainer/developer >
On Tue, 2020-09-08 at 12:35 -0700, Greg Thelen wrote: [...]> This doesn't work with older versions of make. ?make 4.2.1 seems common > now and does not support $(shell command).[...]> https://git.savannah.gnu.org/cgit/make.git/commit/?id=1af314465e5dfe3e8baa839a32a72e83c04f26ef > looks to be required and is in make 4.2.90+. > > The kernel went with > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=913ab9780fc021298949cc5514d6255a008e69f9 > > So we might want: > ? $(shell command -v $(PERL) 2> /dev/null)Right, I've done that now, thanks. Ben. -- Ben Hutchings Design a system any fool can use, and only a fool will want to use it. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20201212/989d6a68/attachment.sig>