89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
9.78k stars 398 forks source link

[Suggestion] Skip empty strings in IFS="¤" loops #1514

Open danonb opened 1 month ago

danonb commented 1 month ago

In the context of distrobox-assemble and depending on a user's shell environment, the IFS="¤" delimiter can result in an empty string within the proceeding loop.

I suggest building in the ability to detect and skip such situations.

This issue would be apparent for cases where fields like 'volume' are described on multiple lines of an *.ini file.

danonb commented 1 month ago
    if [ -n "${volume}" ]; then
        IFS="¤"
        for vol in ${volume}; do
            [ -z "${vol}" ] && continue # Skip empty fields      
            result_command="${result_command} --volume $(sanitize_variable "${vol}")"
        done
    fi