Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Debian Ash with Tabcomplete (unix.stackexchange.com)
3 points by 1vuio0pswjnm7 on Aug 3, 2022 | hide | past | favorite | 2 comments


   #!/bin/sh

   # https://git.kernel.org/pub/scm/utils/dash/dash.git/snapshot/dash-0.5.11.5.tar.gz
   # https://packages.debian.org/source/dash
   # tested:
   # dash-debian-unstable.tar.gz
   # dash-0.5.11.5.tar.gz
   # dash_0.5.11+git20210903+057cd650a4ed.orig.tar.xz
   
   # prerequisite: libedit
   nm /usr/lib/libedit.a|grep -q T.ed_insert||exit 
   nm /usr/lib/libedit.a|grep -q T.rl_complete||exit 
   
   test $1||exec echo usage: $0 dash-source-dir
   
   cd $1||exit
   # compiling debian ash requires Perl and autotools
   ./autogen.sh
   
   ed src/histedit.c << eof
   134a
   el_set(el,EL_BIND,"^I",tabcomplete?"rl-complete":"ed-insert",NULL);
   .
   117a
   el_set(el,EL_SIGNAL,1);
   el_set(el,EL_ADDFN,"rl-complete","readline compatible completion function",_el_fn_complete);
   .
   wq
   eof
   
   ed src/options.c << eof
   103a
   't',
   .
   83a
   "tabcomplete",
   .
   wq
   eof
   
   ed src/options.h << eof
   65c
   #define NOPTS 18
   .
   63a
   #definetabcomplete optlist[17]
   .
   wq
   eof
   
   ./configure --with-libedit
   make
   
   # static linking for void linux
   cd src||exit
   gcc -static -Wall -g -O2 -o dash alias.o arith_yacc.o arith_yylex.o cd.o error.o eval.o exec.o expand.o histedit.o input.o jobs.o mail.o main.o memalloc.o miscbltin.o mystring.o options.o parser.o redir.o show.o trap.o output.o bltin/printf.o system.o bltin/test.o bltin/times.o var.o builtins.o init.o nodes.o signames.o syntax.o -ledit -lcurses
   strip -s dash
   readelf -d dash


Statically-linked dash binary on Void Linux with musl is 456K.

By comparison, dynamically-linked bash on same system is 1.3M. Over twice the size.

Dash is both smaller and faster.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: