UCSF-CBI / rstudio-server-controller

RStudio Server Controller (RSC) - A Tool for Launching a Personal Instance of the RStudio Server
https://github.com/UCSF-CBI/rstudio-server-controller
ISC License
4 stars 2 forks source link

rsc start --debug: syntax error: operand expected (error token is "17565") #103

Closed HenrikBengtsson closed 5 months ago

HenrikBengtsson commented 6 months ago
$ rsc start --debug
...
DEBUG:  - checkpid('17565', '') exit code: 0
/software/c4/cbi/software/rstudio-server-controller-0.16.0/bin/rsc: 
line 689: 17565: syntax error: operand expected (error token is "17565")
DEBUG: rserver_monitor(): sleep
...

That error occurs in:

https://github.com/UCSF-CBI/rstudio-server-controller/blob/739e337b1e3f40e4817cd5a36dd360315fbfcd80/bin/rsc#L687-L692

where pid is defined as an integer, i.e. local -i pid.

HenrikBengtsson commented 5 months ago

Hmm... still don't understand. After adding more debug info, the value that it tries to assign to pid is indeed an integer;

DEBUG: Checking that the 'rserver' process is still running ...
DEBUG: rs_process_status(pid=1207525, hostname=dev3):                                                                               
DEBUG:  - check_pid('1207525', '') exit code: 0, output='DEBUG: check_pid(pid=1207525, hostname=dev3) ... DEBUG: - Checking /proc/12
07525 on current machine (dev3) DEBUG: - dev3:/proc/1207525 exists 1207525 DEBUG: check_pid(pid=1207525, hostname=dev3) ... done '
DEBUG:  - prune_debug(): 1207525                                         
DEBUG:  - pid='1207525'                                                                                                            
bin/rsc: line 694: 1207525: syntax error: operand expected (error token is "1207525")
DEBUG: _RSC_RSERVER_PORT_='3987'                                                                                                   
DEBUG: Checking that the 'rserver' process is still running ... done                                                               
DEBUG: Waiting for background process (PIDs 1207629) to finish ...
HenrikBengtsson commented 5 months ago

Ah, when writing ${res[0]} to file, it reveals that there are stray, invisible symbols;

pid='\u{f}1210729'

which I take as Unicode symbol U+000F, i.e. ASCII 0x0F = ASCII 10 = LF = \n.

HenrikBengtsson commented 5 months ago

This is because the internal prune_debug() fails to prune everything, e.g.

$ printf "%q\n" "$(prune_debug $'\E[m\017326730')"
$'\017326730'