Login | Register
My pages Projects Community openCollabNet

Discussions > dev > make/sh ugliness

Project highlights: Architectural Overview

joist
Discussion topic

Hide all messages in topic

All messages in topic

Re: [joist-dev] make/sh ugliness

Author edk
Full name Ed Korthof
Date 2000-12-18 17:46:30 PST
Message On Mon, Dec 18, 2000 at 05:35:51PM -0800, Jon Stevens wrote:
> How is checking to see if an argument has data as being ugly? I always
> thought that validating your variable data before trying to access it is a
> good thing. :-)

it should be valid to have an empty list. having to check to see if the
list is empty is just ugly ... but this is a general sh / make issue.
and i've never heard anyone call sh programming pretty.

cheers --

ed
--
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
   | Ed Korthof | edk at collab dot net | 650-228-2527 |
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=

Re: [joist-dev] make/sh ugliness

Author Jon Stevens <jon at latchkey dot com>
Full name Jon Stevens <jon at latchkey dot com>
Date 2000-12-18 17:35:51 PST
Message on 12/18/2000 5:28 PM, "Ed Korthof" <edk at collab dot net> wrote:

> that would work. i find it kind of ugly (in the same was as the second
> solution which i outlined, though less so); but i can live with it. i
> still don't think that including this block in Makefile is all that
> helpful, when there's no reason to believe we'll ever use it; and it may
> be confusing.
>
> but i don't care enough to argue those now; unless someone else has a
> strong opinion, i'll use the pattern jon outlined.

How is checking to see if an argument has data as being ugly? I always
thought that validating your variable data before trying to access it is a
good thing. :-)

As for whether or not the code belongs at all...that is a whole different
subject. :-)

-jon

Re: [joist-dev] make/sh ugliness

Author edk
Full name Ed Korthof
Date 2000-12-18 17:28:27 PST
Message On Mon, Dec 18, 2000 at 05:09:03PM -0800, Jon Stevens wrote:
> on 12/18/2000 4:52 PM, "Ed Korthof" <edk at collab dot net> wrote:
>
> > for f in $(HTTPD_CONF_FILES); do \
> > echo " $${f}"; \
> > if [ -f $(HTTPD_CONF_DIR)/$${f} ]; then \
> > mv $(HTTPD_CONF_DIR)/$${f} $(HTTPD_CONF_DIR)/$${f}.orig; \
> > fi; \
> > cp -f $${f}* $(HTTPD_CONF_DIR); \
> > done; \
> > dies unpleasantly if $(HTTPD_CONF_FILES) is empty, as it is in
> > joist/conf/Makefile (HTTPD_CONF_FILES is empty in the corresponding
> > Makefile.config).
>
> Ok, so then why not:
>
> if [ ! -z "$(HTTPD_CONF_FILES)" ] ; then
> for f in $(HTTPD_CONF_FILES); do \
> echo " $${f}"; \
> if [ -f $(HTTPD_CONF_DIR)/$${f} ]; then \
> mv $(HTTPD_CONF_DIR)/$${f} $(HTTPD_CONF_DIR)/$${f}.orig; \
> fi; \
> cp -f $${f}* $(HTTPD_CONF_DIR); \
> done; \
> fi
>
> ??. Or am I missing the point.

that would work. i find it kind of ugly (in the same was as the second
solution which i outlined, though less so); but i can live with it. i
still don't think that including this block in Makefile is all that
helpful, when there's no reason to believe we'll ever use it; and it may
be confusing.

but i don't care enough to argue those now; unless someone else has a
strong opinion, i'll use the pattern jon outlined.

cheers --

ed
--
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
   | Ed Korthof | edk at collab dot net | 650-228-2527 |
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=

Re: [joist-dev] make/sh ugliness

Author Jon Stevens <jon at latchkey dot com>
Full name Jon Stevens <jon at latchkey dot com>
Date 2000-12-18 17:09:03 PST
Message on 12/18/2000 4:52 PM, "Ed Korthof" <edk at collab dot net> wrote:

> for f in $(HTTPD_CONF_FILES); do \
> echo " $${f}"; \
> if [ -f $(HTTPD_CONF_DIR)/$${f} ]; then \
> mv $(HTTPD_CONF_DIR)/$${f} $(HTTPD_CONF_DIR)/$${f}.orig; \
> fi; \
> cp -f $${f}* $(HTTPD_CONF_DIR); \
> done; \
> dies unpleasantly if $(HTTPD_CONF_FILES) is empty, as it is in
> joist/conf/Makefile (HTTPD_CONF_FILES is empty in the corresponding
> Makefile.config).

Ok, so then why not:

if [ ! -z "$(HTTPD_CONF_FILES)" ] ; then
        for f in $(HTTPD_CONF_FILES); do \
          echo " $${f}"; \
          if [ -f $(HTTPD_CONF_DIR)/$${f} ]; then \
            mv $(HTTPD_CONF_DIR)/$${f} $(HTTPD_CONF_DIR)/$${f}.orig; \
          fi; \
          cp -f $${f}* $(HTTPD_CONF_DIR); \
        done; \
fi

??. Or am I missing the point.

-jon

--
Honk if you love peace and quiet.

make/sh ugliness

Author edk
Full name Ed Korthof
Date 2000-12-18 16:52:30 PST
Message hi --

while trying to make our software work on SuSE i encounter issues
similar to the ones which i encountered on Solaris, with makefiles.
specifically, blocks like the following
        for f in $(HTTPD_CONF_FILES); do \
          echo " $${f}"; \
          if [ -f $(HTTPD_CONF_DIR)/$${f} ]; then \
            mv $(HTTPD_CONF_DIR)/$${f} $(HTTPD_CONF_DIR)/$${f}.orig; \
          fi; \
          cp -f $${f}* $(HTTPD_CONF_DIR); \
        done; \
dies unpleasantly if $(HTTPD_CONF_FILES) is empty, as it is in
joist/conf/Makefile (HTTPD_CONF_FILES is empty in the corresponding
Makefile.config).

there are two solutions which i can suggest. my preference is to remove
blocks like these -- joist has never had any httpd conf files, and it's
never likely to need any. afaict the block above was added for symetry
w/ helm. to quote kmaples -- i'd rather have fewer confusing and unused
blocks of code to wade through when tracking something down.

but i can see how taking out & adding back such blocks is a bit annoying
-- it'd be nice if all you had to do to change the behavior was to
change the Makefile.config. an alternate is changing the block above
to:

        for f in "$(HTTPD_CONF_FILES)"; do \
          if [ -z "$f" ] ; then break ; fi ; \
          echo " $${f}"; \
          if [ -f $(HTTPD_CONF_DIR)/$${f} ]; then \
            mv $(HTTPD_CONF_DIR)/$${f} $(HTTPD_CONF_DIR)/$${f}.orig; \
          fi; \
          cp -f $${f}* $(HTTPD_CONF_DIR); \
        done; \

this works on SuSE and Solaris; it may or may not work on other OSes.
it's ugly in its own way.

really -- i'd rather switch to ant. right now. but i don't have time
to do any such thing; so i just want to have a pattern to apply for the
short term, for making our software work with OSes other than RH.

thanks --

ed
--
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
   | Ed Korthof | edk at collab dot net | 650-228-2527 |
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
Messages per page: