HOME and END keys don't work, replaced Busybox with BASH

Hi,
any idea how I can get HOME and END key working with bash as shell?
when I press them I only get ~ as output.

I am currently using 18.06-rc1

Works for me. Perhaps it's an issue with your SSH client?

I am use kitty als client.
but I connect to many ssh hosts and had never before such a issue.
I also have a other problem with bash on openwrt 18.06-rc1:

Directorys/Files are not get expanded with bash - example:

root@AC1750:~# ls -lah /etc/ # FOLLOWED BY DOUBLE TAB

should get me a list of files/directorys - but when I use

root@AC1750:~# ls -lah /etc/pa # FOLLOWED BY DOUBLE TAB

it get completed to /etc/passwd

but not:

root@AC1750:~# ls -lah /etc/pro # FOLLOWED BY DOUBLE TAB

which should get me profile and protocols.

something is really wired.

You have replaced your shell in /etc/passwd for root?
Or you change your shell after logon?

Works for me.

Works for me.

Default OpenWrt.

LuCI openwrt-18.06 branch (git-18.163.60998-c379f00) / OpenWrt 18.06-SNAPSHOT r7109-1961cdf

Also works for me on:

  • 17.01.4
  • 18.06.0-rc1

so how you use than bash?
default is sh - when you not change / start bash - you dont use it.
can you get me output of:

echo $BASH_VERSION

Wait...are you changing your shell from Busybox to something else???

Why???

Nothing displayed:

root@OpenWrt:~# echo $BASH_VERSION

because bash get me more features than the minimal sh. One of my favorites is history and history search.

I could write shell not bash, when I would not specially talk about BASH .... :wink:

Its not minimal sh, it's Busybox.

The built-in one does that, you hit the up button.

root@OpenWrt:~# history
   0 echo $BASH_VERSION
   1 history

Yes, but a lot of the commands and functions you see on the system and command line...are actually built into Busybox.

See: https://www.busybox.net/downloads/BusyBox.html#commands

You'd have to replace Busybox; and all the tools it replaces. Please be advised, installing all this software via separate binaries will take more space and system resources to run.

try to search with CTRL+R :wink:
And this is a openwrt package - and my router has enough space.

I've never used CTRL+R, no clue what it does, I prefer history. (I did look on an Ubuntu machine...).

You missed what I said:

There's over 30 packages:

acpid, addgroup, adduser, adjtimex, ar, arp, arping, ash,
        awk, basename, beep, blkid, brctl, bunzip2, bzcat, bzip2, cal, cat,
        catv, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot,
        chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab,
        cryptpw, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod,
        devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname,
        dos2unix, dpkg, du, dumpkmap, dumpleases, echo, ed, egrep, eject,
        env, envdir, envuidgid, expand, expr, fakeidentd, false, fbset,
        fbsplash, fdflush, fdformat, fdisk, fgrep, find, findfs, flash_lock,
        flash_unlock, fold, free, freeramdisk, fsck, fsck.minix, fsync,
        ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, hd,
        hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id,
        ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, inotifyd,
        insmod, install, ionice, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink,
        iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd,
        last, length, less, linux32, linux64, linuxrc, ln, loadfont,
        loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr,
        ls, lsattr, lsmod, lzmacat, lzop, lzopcat, makemime, man, md5sum,
        mdev, mesg, microcom, mkdir, mkdosfs, mkfifo, mkfs.minix, mkfs.vfat,
        mknod, mkpasswd, mkswap, mktemp, modprobe, more, mount, mountpoint,
        mt, mv, nameif, nc, netstat, nice, nmeter, nohup, nslookup, od,
        openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress,
        pivot_root, pkill, popmaildir, printenv, printf, ps, pscan, pwd,
        raidautorun, rdate, rdev, readlink, readprofile, realpath,
        reformime, renice, reset, resize, rm, rmdir, rmmod, route, rpm,
        rpm2cpio, rtcwake, run-parts, runlevel, runsv, runsvdir, rx, script,
        scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont,
        setkeycodes, setlogcons, setsid, setuidgid, sh, sha1sum, sha256sum,
        sha512sum, showkey, slattach, sleep, softlimit, sort, split,
        start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv,
        svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac,
        tail, tar, taskset, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd,
        time, timeout, top, touch, tr, traceroute, true, tty, ttysize,
        udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq,
        unix2dos, unlzma, unlzop, unzip, uptime, usleep, uudecode, uuencode,
        vconfig, vi, vlock, volname, watch, watchdog, wc, wget, which, who,
        whoami, xargs, yes, zcat, zcip

I hope you find your solution. I've never tried to change the shell on OpenWrt for the reason above. Best wishes!

your don't need to install all them, because sh stays parallel present on openwrt.
This goes really offtopic - it seems that you dont know mush about linux.

I am aware you continue to link the commands to the busybox version. The issue is, I've never experienced someone changes shell on OpenWrt (because of various issues, one you're expriencing now).

I think someone else would be better to explain the issue.

Anyways, despite you think I don't know Linux, confirm that the HOME and END keys and history are programmed to work on the version compiled for OpenWrt.

Been a long time since I used bash on OpenWrt, as pretty much all the things you note as desirable can be built into Busybox ash. They are not turned on by default, so you will have to build your own image to get the extra functionality.

iirc correctly, one hurdle in getting things functioning was to edit /etc/passwd, there could be more...

1 Like

I am using this line in rc.local

test -x /bin/bash && sed '/^root/ s_/bin/.*_/bin/bash_g' -i /etc/passwd || sed '/^root/ s_/bin/.*_/bin/ash_g' -i /etc/passwd

so it is easy to update without any stress.

I don't want to compile my own firmware image - only to have such feature - thats really to mush.

I just like to use bash history search (ctrl+s), because I heavily use it on all my maintained systems with bash and it speed up my work.

And there are other advanced bash things, which are not availible in busybox. To say a new example: PIPESTATUS

http://lists.busybox.net/pipermail/busybox/2007-July/062422.html

I didn't know, that we need to start a fundamental discussion about shells, when I was asking if someone knows how to solve my problem. :roll_eyes:

oh -- and busybox history is very limited - to how many entry's ?! :wink:

I set in bash this, which gives me 1000 commands history:

root@AC1750:~# cat /etc/profile.d/bash.sh
#!/bin/sh

[ -z "$PS1" ] && return
[ -z "$BASH_VERSION" ] && return

shopt -s checkwinsize

HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

My intent was not to start a shell discussion, I would point you at a post I put on the OpenWrt forum years back, but well..

At any rate since you ask, what ever set it to:

CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_HISTORY=512
CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY=y
CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y

My intent was not to start a shell discussion

It was not addressed to you :smile:

At any rate since you ask, what ever set it to

yes, your see it is fixed compiled in - not really flexible - it is bad, when I want to fit it to my needs, that I need to recompile the binary.

long story short - no one has a idea, why bash don't work properly.

Maybe someone else..... :face_with_monocle: