# Re: \[PATCH\] Fixed non portable use of expr, and incorrect use of test -eq for string comparison.

- From: martin f krafft \<hidden\>
- Date: 2016-06-15 22:43:30 
- List: git
- Page: https://ratatoskr.run/git/2016/06/7313491
- Thread: https://ratatoskr.run/git/2016/06/7313443/t.md

```text
also sprach David Jack Olrik [ref] [2007.08.22.1402 +0200]:
> -	if test "`expr index $httpd_only /`" -eq '1' || \
> +	if test "`echo $httpd_only | cut -c 1`" = '/' || \

how about

  if [ "$httpd_only" != "${httpd_only#/}" ]; then

that should do the same and does so without external processes.

>  				which $httpd_only >/dev/null

This is also not really portable. I suggest the use of

  command -v $http_only

first, that's shell-internal as well, and second, it's
/more/ portable than which, but also not entirely.

http://www.debian.org/doc/developers-reference/ch-best-pkging-practices.en.html#s-bpp-debian-maint-scripts

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
"of course the music is a great difficulty.
 you see, if one plays good music, people don't listen,
 and if one plays bad music people don't talk."
                                                        -- oscar wilde
 
spamtraps: madduck.bogus@madduck.net
```

## Attachments

- [digital\_signature\_gpg.asc](https://ratatoskr.run/git/2016/06/7313491/attachment/0) (application/pgp-signature, 189 bytes)
