Segmentation fault with dialog
I'm obtaining a segmentation fault with the adhering to manuscript when it is extra that youngster dir past the pwd. The program eliminates with the mistake message and also I need to reset the shell.
As an example: I start in /
and also run the manuscript. I browse to from /
to /etc
simply great. When I attempt to head to /etc/httpd/
that is when I get the sector mistake.
An additional instance: I start the manuscript with lsgui /etc
and also then it will certainly present that dir yet when I attempt to browse to an additional dir it mistakes once more.
#!/bin/bash
output=${1-$PWD}
IFS=$'\r\n' lss=($(ls -1 $output))
for ((i=0;i<${#lss[@]};i++));do
x+=($i \"${lss[$i]}\")
done
justdir=($(basename $output))
desc=($(grep $justdir /root/lsgui.conf))
if [ -z $desc ]
then
desc=$output
fi
dialog --keep-tite --title 'lsgui' --menu $desc 40 70 ${#lss[@]} ${x[@]} 2>/tmp/lsgui.$$
if [ $? -gt 0 ]; then
rm -f /tmp/lsgui.$$
clear
exit 0
fi
result=`cat /tmp/lsgui.$$`
case $? in
0)
if [ -d ${lss[$result]} ];then
/root/lsgui $output/${lss[$result]}
else
dialog --keep-tite --title "${lss[$result]}" --textbox $output/${lss[$result]} 40 70
fi
esac
UPDATE
The trouble was if [ -d ${lss[$result]} ];then
. It was aiming to open a documents in a dir. This was dealt with by transforming the previous declaration to if [ -d $output/${lss[$result]} ];then
. I possibly can have protected against the segfault to begin with by examining if the dialog textbox was a documents or otherwise.
Related questions