From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 16 14:55:24 2013 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1F826203 for ; Mon, 16 Dec 2013 14:55:24 +0000 (UTC) Received: from mail-ea0-x235.google.com (mail-ea0-x235.google.com [IPv6:2a00:1450:4013:c01::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AA1AA167E for ; Mon, 16 Dec 2013 14:55:23 +0000 (UTC) Received: by mail-ea0-f181.google.com with SMTP id m10so2304649eaj.12 for ; Mon, 16 Dec 2013 06:55:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:subject:date:content-type :content-transfer-encoding:in-reply-to:references; bh=7T5J9NNYVtm31/kER4Qh3AwxpRX6lZ1PYy3FW/RheTA=; b=Kymzb8kWLVlyCfBK2O3Nqu0UeUmVChZhL3oSlNguHukbznwgithSDpDGfJXnAy3Kf7 PaEjJUf1Pxefn9b7alUxeBrzhFHgtuDWl/YtieXwy/tf+Hf3z2MxpQxV6E7G1pqOFST1 po0Pz46xMWeBSF5Kr9I96zRPb2N3zYtbvO9uKTN5w3DL0vUYNR13KYDLeC5udOq3pXHy iGXLUxhg0hw0abjsbhgxFc/YaCoyyQG3XXDyPNW2YMzjwDolbNfmA04aUW+xz8JMa+LU QptGzFjKLpi8mj9S+G1JZo7EwHv9SaBwEet/dsjR0S5A6zPJqCwL0I5bC0KuedWZbNhM 9WKg== X-Received: by 10.14.113.199 with SMTP id a47mr17419119eeh.41.1387205722047; Mon, 16 Dec 2013 06:55:22 -0800 (PST) Received: from DOMYPC ([82.193.208.225]) by mx.google.com with ESMTPSA id n1sm43102384eep.20.2013.12.16.06.55.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Dec 2013 06:55:20 -0800 (PST) Message-ID: <20131216.145522.249.2@DOMY-PC> From: rank1seeker@gmail.com To: hackers@freebsd.org Subject: Re: Interactive /bin/sh Date: Mon, 16 Dec 2013 15:55:22 +0100 Content-Type: text/plain; charset="Windows-1250" Content-Transfer-Encoding: quoted-printable In-Reply-To: <20131216092252.784cd34edde5f4299f9dac4b@yamagi.org> References: <20131215.105840.948.1@DOMY-PC> <20131216092252.784cd34edde5f4299f9dac4b@yamagi.org> X-Mailer: POP Peeper (3.8.1.0) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Dec 2013 14:55:24 -0000 > An alternate viewpoint: I would prefer that /bin/sh remain as lean = and=0D=0A> mean as possible, conforming to posix and especially NOT = becoming=0D=0A> bloated with interactive usability stuff. If you want a = user-friendly=0D=0A> bourne shell and can afford the memory and cycle = bloat, use bash. =0D=0A>=0D=0A> Please keep /bin/sh lightweight for = embedded and dedicated-purpose=0D=0A> systems that need a = posix-conforming shell without a ton of overhead.=0D=0A=0D=0AI'm against = code-bloat. We are talking here about minimalistic interactive shell, = which is compatible with base scripts.=0D=0AScripting in [t]csh and just = .cshrc, is a hell (and it basically aliases to 'sh' scripts which = actually do the real work). I use it only because of = interactivnes.=0D=0AI don't have many interactive needs and sh is just = metting those.=0D=0A=0D=0ANow, BEFORE any code is added, let see what do = we have available ATM 9.2 RELEASE...=0D=0A=0D=0Apath completion =3D> = function which provides it, searches CURRENT dir=0D=0ASo, in order to = implement command completion, we need to use SAME EXISTING function of = path completion, in EACH dir specified in PATH variable=0D=0A+ once this = has been done, results can be buffered, as PATH's dir are static (upon = port install, one would 'rehash' which would need = implementation)=0D=0A=0D=0AThere is even more useful EXITING but = UNDOCUMENTED = code:=0D=0Ahttp://svnweb.freebsd.org/base/head/bin/sh/parser.c?view=3Dmarkup=0D=0A=0D=0AI = wanted current dir, to dinamically change in prompt whenever I 'cd' = somwhere:=0D=0A--=0D=0APS1=3D$PWD # Won't work as it is = static!=0D=0A--=0D=0A=0D=0AAt above URL, looking at lines 1939-2002 where = 'switch' resides:=0D=0A--=0D=0A# \h - local hostname=0D=0A# \w - working = dir (full path)=0D=0A# \$ - becomes '$' for normal users, '#' for = root=0D=0APS1=3D"$USER@\h:\w \$ "; export PS1=0D=0A--=0D=0ANow I have = dinamic current dir in prompt. (I even colorized each part of prompt, but = coloring code here would be too long and messy)=0D=0AI would just like = another one \something, which would give last CMD's exit code, to be part = of a prompt.=0D=0ACost would be just 1 additional 'case' in above = 'switch' statement=0D=0A=0D=0A=0D=0A> After svn r244941 - which fixed a = bug preventing ed-search-next-history=0D=0A> and ed-search-prev-history = from working - this should be possible. To=0D=0A> bind them on "Page Up" = and "Page Down":=0D=0A> - bind "\e[5~" ed-search-prev-history=0D=0A> - = bind "\e[6~" ed-search-next-history=0D=0A=0D=0ALooks like what I wanted = to be implemented (Prefix-based history navigation), is already here. = ;)=0D=0AIt works slightly different then in [t]csh, that is, it matches = string anywhere in history of command, while [t]csh's implementation only = from begening.=0D=0ABut it doesn't matter, I like it anyway. Just a few = more key presses and occurance is narrowed enough.=0D=0A=0D=0A> But as = far as I know, even with those bindings /bin/sh is still missing=0D=0A> a = way to save the command history to disk and load it back at = startup.=0D=0A=0D=0AWell, to me it isn't so important, but it can be = emulated for login shell via custom functions that are auto called upon = login, via ~/.profile and ~/.shrc=0D=0AUpon logout:=0D=0A fc -ln > = .sh_history=0D=0AHowever, I don't know how to fill it back into builtin = 'fc' at login ... :P=0D=0A=0D=0A=0D=0ATo sum up:=0D=0AJust add path = completion with rehash & last CMD's exit code for custom = prompt.=0D=0AHistory file, if others want.=0D=0A=0D=0A=0D=0A=0D=0ADomagoj = Smol=E8i=E6