1 |
>>>>> On Thu, 06 Sep 2012, Gregory M Turner wrote: |
2 |
|
3 |
> Hello, in my overlay I need to fix a bunch of issues that crop up when |
4 |
> implementing EPREFIX construction in scripts due to Cygwin's |
5 |
> idiosyncratic, but POSIX-compliant, handling of paths beginning with |
6 |
> "//" (Cygwin does some arguably pathological stuff when such paths are |
7 |
> used). |
8 |
|
9 |
> Almost all of these stem from the careless tacking of "ROOT" onto |
10 |
> "EPREFIX" in bash-scripts, i.e., as in this (made-up) bash-script snippet: |
11 |
|
12 |
> ${ROOT:=/} |
13 |
> EPREFIX="@GENTOO_PORTAGE_EPREFIX@" |
14 |
> EROOT="${ROOT}${EPREFIX}" |
15 |
|
16 |
> When ROOT is undefined or empty, this script will assign "//foo" to |
17 |
> EROOT and bad things will happen in Cygwin. |
18 |
|
19 |
> Several correct-ish solutions exist, i.e., in the above we could change |
20 |
> the concatenation statement to read: |
21 |
|
22 |
> EROOT="${ROOT}${EPREFIX#/}" |
23 |
|
24 |
I'd rather do it the other way around: |
25 |
EROOT=${ROOT%/}${EPREFIX} |
26 |
|
27 |
Reason: EPREFIX is guaranteed to start with a slash, whereas for ROOT |
28 |
I wouldn't be so sure that it always ends with one. |
29 |
|
30 |
Ulrich |