Compgen return results in different order than usual

bug

#1

Hello,

Just wandering why my “bash-complete” tests failed under Travis but working great on my desktop even under travis docker image and found that “compgen” does not return his results in the same order as it does normally.

Under Travis CI:

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
$ dpkg -l bash-completion
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                 Architecture            Description
+++-====================================-=======================-=======================-=============================================================================
ii  bash-completion                      1:2.1-4.2ubuntu1.1      all                     programmable completion for the bash shell
$ env -i bash --norc --noprofile
$ env
PWD=/home/travis/build/rockandska/fzf-obc-tests/test
SHLVL=1
_=/usr/bin/env
$ tree structure/
structure/
|-- d1
|-- d1\ 0
|-- d10
|   |-- xxx
|   `-- yyy\ yyy
|-- d2
|-- d3
|-- d4
|-- d5
|-- d6
|-- d7
|-- d8
|-- d9
|-- xxx
|-- xxx\ xxx
`-- yyy

11 directories, 5 files
$ compgen -d -- "structure/"
structure/d4
structure/d2
structure/d6
structure/d1
structure/d1 0
structure/d7
structure/d9
structure/d10
structure/d3
structure/d8
structure/d5

Under my laptop (bionic) and docker travis image (travisci/ci-sardonyx:packer-1547455648-2c98a19 ) the results are the same as bellow

$ docker run --name ubuntu-xenial -dit travisci/ci-sardonyx:packer-1547455648-2c98a19
$ docker exec -ti ubuntu-xenial /bin/bash
# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
# apt-get install tree
# dpkg -l bash-completion
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
ii  bash-completion                                       1:2.1-4.2ubuntu1.1              all                             programmable completion for the bash shell
# env -i bash --norc --noprofile
# env
PWD=/root
SHLVL=1
_=/usr/bin/env
# mkdir -p /tmp/structure/d{1,2,3,4,5,6,7,8,9,10,'1 0'}
# touch /tmp/structure/{d10/xxx,d10/'yyy yyy',xxx,'xxx xxx',yyy}
# cd /tmp/
/tmp# tree structure/
structure/
|-- d1
|-- d1\ 0
|-- d10
|   |-- xxx
|   `-- yyy\ yyy
|-- d2
|-- d3
|-- d4
|-- d5
|-- d6
|-- d7
|-- d8
|-- d9
|-- xxx
|-- xxx\ xxx
`-- yyy

11 directories, 5 files
/tmp# compgen -d -- "structure/"
structure/d6
structure/d9
structure/d4
structure/d8
structure/d3
structure/d1
structure/d5
structure/d2
structure/d7
structure/d1 0
structure/d10

Since i tried even with clean env to avoid the shell to be clutter by env settings, i don’t get why the results are not the same and prevent me to write acceptance testing.

Regards,