1 |
Alec Warner wrote: |
2 |
> |
3 |
> The correct way to mess with each is to save the old value (IFS) or |
4 |
> restore the previous setting (shopts). |
5 |
> |
6 |
> local OLDIFS="$IFS" |
7 |
> ...do stuff |
8 |
> IFS="$OLDIFS" |
9 |
> |
10 |
> set -s extglob |
11 |
> ...do stuff |
12 |
> set -u extglob |
13 |
> |
14 |
> If you change a bunch of shell options or have no idea what you changed; |
15 |
> you can also do fun magic like: |
16 |
> |
17 |
> local SHOPTS=$(shopt -p) |
18 |
> ..do stuff |
19 |
> eval "$SHOPTS" |
20 |
> |
21 |
> which should restore the previous options. |
22 |
> |
23 |
Note, the examples above could be improved by prefixing your variables |
24 |
(you don't want global collisions, trust me) |
25 |
|
26 |
So fex KDE_SHOPTS or KDE_OLD_IFS instead of just OLD_IFS. |
27 |
|
28 |
> Thanks, |
29 |
> -Alec Warner |
30 |
|
31 |
-- |
32 |
gentoo-dev@g.o mailing list |