Showing 1 changed files with 9 additions and 5 deletions
+9 -5
.fgfs/fgfs_function
... ...
@@ -64,9 +64,13 @@ function fgfs () {
64 64
         esac
65 65
     }
66 66
     function ld_library_path () {
67
-# TODO: prendre en compte les éventuels caractères gênants comme "espace" ou ":" dans $FGDIR
68
-# TODO: ne pas surajouter si déjà présent dans LD_LIBRARY_PATH
69
-        print ${(j,:,):-$(ls -d $FGDIR/install/*/lib)}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}
67
+        IFS_=$IFS
68
+        IFS=$'\n'
69
+        for lib in $(ls -d $FGDIR/install/*/lib); do
70
+            egrep -q "(^|:)$lib(:|$)" <<< "${LD_LIBRARY_PATH}" || LD_LIBRARY_PATH="${lib}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
71
+        done
72
+        IFS=$IFS_
73
+        export LD_LIBRARY_PATH
70 74
     }
71 75
     local aircrafts="$FGADDON/Aircraft"
72 76
     local fgfs_args=("--fg-root=$FGDIR/source/fgdata")
... ...
@@ -157,7 +161,7 @@ function fgfs () {
157 161
                         --show-aircraft --fg-aircraft=$FGADDON/Aircraft
158 162
                         --help          --verbose
159 163
                     )
160
-                    export LD_LIBRARY_PATH=$(ld_library_path)
164
+                    ld_library_path
161 165
                     $FGDIR/install/flightgear/bin/fgfs $fgfs_arg ${complement[$fgfs_arg]} 2>/dev/null | pager
162 166
                     return
163 167
                     ;;
... ...
@@ -171,7 +175,7 @@ function fgfs () {
171 175
         fgfs_args+=(--igc=file,out,1,$(date +%Y%m%d-%H%M-${${${fgfs_args[(r)--aircraft=*]}#--aircraft=}:-$(sed -rn 's|^.+aircraft>(.+)</aircraft.+$|\1|p' $FGDIR/source/fgdata/defaults.xml)}.igc))
172 176
     fi
173 177
 
174
-    export LD_LIBRARY_PATH=$(ld_library_path)
178
+    ld_library_path
175 179
 
176 180
     echo ${fgfs_args[@]}
177 181
 # TODO: ne lancer avec primusrun que si c'est nécesaire, d'autres solution existent ?