xcp icon indicating copy to clipboard operation
xcp copied to clipboard

terminfo database

Open DSJ2 opened this issue 8 months ago • 3 comments

When I ssh to an XCP host from inside screen on a Fedora41 desktop, I get

-bash: [: -ge: unary operator expected

and the terminal colors don't work.


I've tracked it down to this test

[ $(tput colors 2>/dev/null) -ge 8 ]

in /etc/profile.d/xcp-ng-prompt.sh


Here is a log of a session that shows the problem:

mydesktop:~$ ssh lab1
Last login: Fri Mar  7 09:48:17 2025 from mydesktop
-bash: [: -ge: unary operator expected

# echo $TERM
TERM=screen.xterm-256color

# tput colors
tput: unknown terminal "screen.xterm-256color"

# ls /usr/share/terminfo/s/
screen           screen.konsole  screen.teraterm       simpleterm   sun1
screen-16color   screen.linux    screen.vte            st           sun2
screen-256color  screen.mlterm   screen.xterm-new      st-16color
screen.Eterm     screen.mrxvt    screen.xterm-r6       st-256color
screen.gnome     screen.rxvt     screen.xterm-xfree86  sun

# export TERM=screen-256color

# tput colors
256

DSJ2 avatar Mar 07 '25 15:03 DSJ2

Thanks for the report. Forwarding to the team.

stormi avatar Mar 12 '25 16:03 stormi

The root cause is in /etc/profile.d/xcp-ng-prompt.sh.

stormi avatar Mar 12 '25 16:03 stormi

Adding double quotes around $(...) should fix the syntax error.

ydirson avatar Mar 14 '25 15:03 ydirson

Hi,

May I ask @DSJ2 which version of xcp-ng were you using because 8.3 has this terminfo:

rpm -qf  /usr/share/terminfo/s/screen.xterm-256color
ncurses-base-6.4-6.20240309.xcpng8.3.noarch

Anyway the issue can be easly reproduced for other undeclared TERMs , on xcp-ng-release-config-8.3.0-32.x86_64 (and probably earlier versions) eg:

TERM=''  ssh $host

-bash: [: -ge: unary operator expected
[13:53 xcp-ng-pcl-11 ~]# echo $PS1
[\A \h \W]\$

I think @ydirson proposal is worth having, so I have improved it a bit at, please review the fix at:

https://github.com/xcp-ng/xcp-ng-release/pull/52

May it be backported if there any traction

rzr avatar Nov 06 '25 12:11 rzr