AOSC-Archive / autobuild3

AOSC OS package maintenance toolkit (version 3)
https://aosc.io
GNU General Public License v2.0
24 stars 17 forks source link

Libs loading: Leave no extra |'s. #23

Closed Artoria2e5 closed 9 years ago

Artoria2e5 commented 9 years ago

This may help with array spliting since splited[0] would actually contain something.

So the lib loading would look like:

# base
ABLIBS='base'
# foo is a non-base lib.
ABLIBS+='|foo'
# when we need to list the libs:
_IFS="$IFS" IFS=\| _ablibs=($ABLIBS) IFS="$_IFS"
for lib in "${_ablibs[@]}"; ...

Sadly the regex may look awful:

# ^mod|, ^mod$, |mod|, |mod$
ablibloaded(){ grep -Eq "(^|\|)$1(\||$)" <<< "$ABLIBS"; }

Or shall we use an array directly instead?

Artoria2e5 commented 9 years ago

Well actually the original

ABLIBS='|base|'
ABLIBS+='foo|'

is a good idea, since it would be easier to read the regex.

When it comes to arrays, with an assumption that sane programmers do not put spaces into lib names, we can use grep -E "\<$i\>" <<< "${ablibs[@]}" to do a whole-word matching.

Icenowy commented 9 years ago

Your IQ is not higher than me at all, and the original '|base|' design cost me several days to think.

Artoria2e5 commented 9 years ago

And a latex-iron, rounder wheel like arrays is much smoother than your days-made rough wooden wheel.

IQ is not a vaild reason for writing cryptic and fucked-up code. Human create, use and reuse tools.

MingcongBai commented 9 years ago

So this is closed. I was going to remove the 2 of you guys' comments, and I've just decided not to. Flame war is totally unnecessary, well at least to me. This is not a good year for us already due to that **\ NCEE, we DO NOT NEED MORE OF THIS.

To change a code, we can do either one of these:

  1. Make PRs, but not direct pushes, and we may discuss then;
  2. Omit unattended discussion, push first, then talk, and change for the good;

Again, we are to discuss about coding style in AOSCC, I mean, you two may just calm down for a month or so... it is fine... To me, a not-so-good coder it was not such a big deal to just look at two distinct coding style, it just takes time and that's exactly why we should discuss such thing.

Sorry to bother you guys but... anyways.