Attached is a patch for sash. It enables readline support. The patch
is something I made quite some time ago for myself. It replaces the
-misc patch (includes the same changes plus the readline stuff). The
binary size of sash is increased about 100 KB but I think readline
support is worth that much.

-- 
[ Below is a random fortune, which is unrelated to the above message. ]
There's no easy quick way out, we're gonna have to live through our
whole lives, win, lose, or draw.
                -- Walt Kelly
Summary: A statically linked shell, including some built-in basic commands.
Name: sash
Version: 3.3
Release: 3mdk
Copyright: GPL
Group: System Environment/Shells
Source0: http://www.tip.net.au/~dbell/sash-%{version}.tar.bz2
Patch0: sash-%{version}-misc+readline.patch.bz2
Buildroot: /var/tmp/sash-root

%description
Sash is a simple, standalone, statically linked shell which includes
simplified versions of built-in commands like ls, dd and gzip.  Sash
is statically linked so that it can work without shared libraries, so
it is particularly useful for recovering from certain types of system
failures. Sash can also be used to safely upgrade to new versions of
shared libraries.

%prep
%setup -q
%patch0 -p1 -b ".misc"

%build
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"

%install
mkdir -p $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT/usr/man/man8

install -s -m755 sash $RPM_BUILD_ROOT/sbin
install -m644 sash.1 $RPM_BUILD_ROOT/usr/man/man8/sash.8

bzip2 -9f $RPM_BUILD_ROOT/usr/man/*/*

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/sbin/sash
/usr/man/man8/sash.8.bz2

%changelog
* Sat Feb 26 2000 David Hedbor <[EMAIL PROTECTED]> 
- Added readline support.

* Tue Oct 26 1999 Chmouel Boudjnah <[EMAIL PROTECTED]>
- Build release.

* Thu Aug 05 1999 Chmouel Boudjnah <[EMAIL PROTECTED]>
- 3.3.

* Sat Apr 10 1999 Bernhard Rosenkraenzer <[EMAIL PROTECTED]>
- Mandrake adaptions
- bzip2 man/info pages
- add de locale

* Wed Feb 24 1999 Preston Brown <[EMAIL PROTECTED]>
- Injected new description and group.

* Fri Dec 18 1998 Preston Brown <[EMAIL PROTECTED]>
- bumped spec number for initial rh 6.0 build
diff -C 3 -r sash-3.3/Makefile sash-3.3-patched/Makefile
*** sash-3.3/Makefile   Sun Apr 18 07:18:46 1999
--- sash-3.3-patched/Makefile   Fri Feb 25 23:58:37 2000
***************
*** 5,13 ****
  # The HAVE_EXT2 definition adds the -chattr and -lsattr comamnds.
  #
  
! CFLAGS = -O3 -Wall -Wmissing-prototypes -DHAVE_GZIP -DHAVE_EXT2
  LDFLAGS = -static -s
! LIBS = -lz
  
  
  BINDIR = /bin
--- 5,14 ----
  # The HAVE_EXT2 definition adds the -chattr and -lsattr comamnds.
  #
  
! #CFLAGS = -O3 -Wall -Wmissing-prototypes -DHAVE_GZIP -DHAVE_EXT2
! CFLAGS = $(RPM_OPT_FLAGS) -DHAVE_GZIP -DHAVE_EXT2 -DHAVE_READLINE
  LDFLAGS = -static -s
! LIBS = -lz -lreadline -lncurses
  
  
  BINDIR = /bin
diff -C 3 -r sash-3.3/cmds.c sash-3.3-patched/cmds.c
*** sash-3.3/cmds.c     Thu Jun  3 14:42:39 1999
--- sash-3.3-patched/cmds.c     Fri Feb 25 23:58:37 2000
***************
*** 16,23 ****
  #include <grp.h>
  #include <utime.h>
  #include <errno.h>
  #include <linux/fs.h>
! 
  
  void
  do_echo(int argc, const char ** argv)
--- 16,24 ----
  #include <grp.h>
  #include <utime.h>
  #include <errno.h>
+ /*
  #include <linux/fs.h>
! */
  
  void
  do_echo(int argc, const char ** argv)
diff -C 3 -r sash-3.3/sash.c sash-3.3-patched/sash.c
*** sash-3.3/sash.c     Wed Jun 16 04:02:38 1999
--- sash-3.3-patched/sash.c     Sat Feb 26 00:06:47 2000
***************
*** 1,4 ****
--- 1,5 ----
  /*
+ 
   * Copyright (c) 1999 by David I. Bell
   * Permission is granted to use, distribute, or modify this source,
   * provided that this copyright notice remains intact.
***************
*** 13,21 ****
  #include <errno.h>
  
  #include "sash.h"
  
  
! static const char * const     version = "3.3";
  
  
  /*
--- 14,26 ----
  #include <errno.h>
  
  #include "sash.h"
+ #ifdef HAVE_READLINE
+ #include <readline/readline.h>
+ #include <readline/history.h>
+ #endif
  
  
! static const char * const     version = "3.3-readline";
  
  
  /*
***************
*** 479,485 ****
         */
        if (!quietFlag && isatty(STDIN))
        {
!               printf("Stand-alone shell (version %s)\n", version);
  
                if (aliasFlag)
                        printf("Built-in commands are aliased to standard commands\n");
--- 484,491 ----
         */
        if (!quietFlag && isatty(STDIN))
        {
!               printf("Stand-alone shell (version %s)\n"
!                      "Readline support added by David Hedbor <[EMAIL PROTECTED]>\n", 
version);
  
                if (aliasFlag)
                        printf("Built-in commands are aliased to standard commands\n");
***************
*** 523,528 ****
--- 529,538 ----
        int     cc;
        BOOL    ttyFlag;
        char    buf[CMD_LEN];
+ #ifdef HAVE_READLINE
+       char *rlbuf;
+       char *cp;
+ #endif
  
        if (sourceCount >= MAX_SOURCE)
        {
***************
*** 551,559 ****
  
        while (TRUE)
        {
!               if (ttyFlag)
                        showPrompt();
! 
                if (intFlag && !ttyFlag && (fp != stdin))
                {
                        fclose(fp);
--- 561,570 ----
  
        while (TRUE)
        {
! #ifndef HAVE_READLINE
!         if (ttyFlag)
                        showPrompt();
! #endif
                if (intFlag && !ttyFlag && (fp != stdin))
                {
                        fclose(fp);
***************
*** 561,567 ****
  
                        return;
                }
!       
                if (fgets(buf, CMD_LEN - 1, fp) == NULL)
                {
                        if (ferror(fp) && (errno == EINTR))
--- 572,593 ----
  
                        return;
                }
! #ifdef HAVE_READLINE
!               if(prompt)
!                       cp = prompt;
!               else
!                       cp = "> ";
!               if(fp == stdin) {
!                       rlbuf = readline(cp);
!                       if(rlbuf) {
!                               if(*rlbuf)
!                                       add_history(rlbuf);
!                               command(rlbuf);
!                               free(rlbuf);
!                       }
!               } else {
! #endif
!                       
                if (fgets(buf, CMD_LEN - 1, fp) == NULL)
                {
                        if (ferror(fp) && (errno == EINTR))
***************
*** 585,590 ****
--- 611,619 ----
                buf[cc] = '\0';
  
                command(buf);
+ #ifdef HAVE_READLINE
+            }
+ #endif
        }
  
        if (ferror(fp))
***************
*** 1233,1239 ****
  static void
  usage(void)
  {
!       fprintf(stderr, "Stand-alone shell (version %s)\n", version);
        fprintf(stderr, "\n");
        fprintf(stderr, "Usage: sash [-a] [-q] [-c command] [-p prompt]\n");
  
--- 1262,1269 ----
  static void
  usage(void)
  {
!       fprintf(stderr, "Stand-alone shell (version %s).\n"
!               "Readline support added by David Hedbor <[EMAIL PROTECTED]>\n", 
version);
        fprintf(stderr, "\n");
        fprintf(stderr, "Usage: sash [-a] [-q] [-c command] [-p prompt]\n");
  

Reply via email to