Re: invoke tilde expansion on quoted string

2013-04-09 Thread Greg Wooledge
On Tue, Apr 09, 2013 at 11:01:49AM -0600, Bob Proulx wrote: > I am pretty sure that getent is not available on HP-UX for an example > of a classic legacy Unix system. I can confirm this up through 11.11: imadev:~$ uname -a HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license imadev:~$ type

Re: invoke tilde expansion on quoted string

2013-04-09 Thread Bob Proulx
Greg Wooledge wrote: > Linda Walsh wrote: > > Greg Wooledge wrote: > > > getent(1) is fine where it's available, but it's not a standard tool, > > > so you can only use it on systems that have it. > > > Have you encountered it on other linux systems? > > It is present on Debian 3.1 (the oldest De

Re: invoke tilde expansion on quoted string

2013-04-09 Thread Greg Wooledge
On Mon, Apr 08, 2013 at 05:13:46PM -0700, Linda Walsh wrote: > Greg Wooledge wrote: > > getent(1) is fine where it's available, but it's not a standard tool, > > so you can only use it on systems that have it. > Have you encountered it on other linux systems? It is present on Debian 3.1 (the olde

Re: invoke tilde expansion on quoted string

2013-04-08 Thread Linda Walsh
Greg Wooledge wrote: > On Sun, Apr 07, 2013 at 01:13:09AM -0700, Linda Walsh wrote: >>> getent passwd 'Domain Administrator' >> Domain Administrator:x:500:18:Domain Admin accnt:/home/root:/bin/bash > > getent(1) is fine where it's available, but it's not a standard tool, > so you can only use it

Re: invoke tilde expansion on quoted string

2013-04-08 Thread Greg Wooledge
On Sun, Apr 07, 2013 at 01:13:09AM -0700, Linda Walsh wrote: > > getent passwd 'Domain Administrator' > Domain Administrator:x:500:18:Domain Admin accnt:/home/root:/bin/bash getent(1) is fine where it's available, but it's not a standard tool, so you can only use it on systems that have it. If on

Re: invoke tilde expansion on quoted string

2013-04-07 Thread Linda Walsh
Eric Blake wrote: > Even if your system allows shell metacharacters in usernames, tilde > expansion does not. I never thought of that -- I seemed like there should be a get command that access the appropriate library by using your systems's configuration. Unfortunately, it looks like i

Re: invoke tilde expansion on quoted string

2013-04-04 Thread Eric Blake
On 04/04/2013 07:34 AM, Greg Wooledge wrote: > # Sanitize user before feeding it to eval. > # You must adjust this code based on what characters are legal in your > # system's usernames. If your system allows shell metacharacters in > # usernames, you are screwed. Just give up now

Re: invoke tilde expansion on quoted string

2013-04-04 Thread Greg Wooledge
On Thu, Apr 04, 2013 at 09:17:00PM +0800, Chris Down wrote: > Perhaps my reply here[1] can help out. Only looked briefly, but it seems it > could at least eliminate the calls to eval (although it doesn't support some > more rare tilde expansions). > > Chris > > 1: http://lists.gnu.org/archive/htm

Re: invoke tilde expansion on quoted string

2013-04-04 Thread Chris Down
On 2013-04-04 07:11, Eric Blake wrote: > Given that the topic of tilde-completion has recently come up (again), I > wanted to point out: Perhaps my reply here[1] can help out. Only looked briefly, but it seems it could at least eliminate the calls to eval (although it doesn't support some more rar

Re: invoke tilde expansion on quoted string

2013-04-04 Thread Eric Blake
On 11/14/2011 07:23 AM, Freddy Vulto wrote: > This is used in the bash-completion package: Given that the topic of tilde-completion has recently come up (again), I wanted to point out: > > ---8<--- > > # Expand variable starting wi

Re: invoke tilde expansion on quoted string

2011-12-12 Thread Greg Wooledge
On Sun, Dec 11, 2011 at 04:28:49PM +0800, Yang Chengwei wrote: > On Sat, Nov 12, 2011 at 01:42:16PM +0800, Peng Yu wrote: > > I'm wondering if I already have a string variable, is there a bash > > native to do tilde expansion on it. > > > > var='~/..' > > cd $var#how to change this line? It sound

Re: invoke tilde expansion on quoted string

2011-12-11 Thread Yang Chengwei
On Sat, Nov 12, 2011 at 01:42:16PM +0800, Peng Yu wrote: > Hi, > > I know from the document that tilde expansion only works if the string > is unquoted (see below) > > ~$ cd '~/..' > -bash: cd: ~/..: No such file or directory > ~$ cd ~/.. > /Users$ > > I'm wondering if I already have a string va

Re: invoke tilde expansion on quoted string

2011-11-14 Thread Freddy Vulto
This is used in the bash-completion package: ---8<--- # Expand variable starting with tilde (~) # We want to expand ~foo/... to /home/foo/... to avoid problems when # word-to-complete starting with a tilde is fed to commands and endi

Re: invoke tilde expansion on quoted string

2011-11-12 Thread Eric Blake
On 11/12/2011 07:53 AM, Geir Hauge wrote: > 2011/11/12 Chris F.A. Johnson > >> On Fri, 11 Nov 2011, Peng Yu wrote: >> >>> I'm wondering if I already have a string variable, is there a bash >>> native to do tilde expansion on it. >>> >>> var='~/..' >>> cd $var#how to change this line? >>> >> >> e

Re: invoke tilde expansion on quoted string

2011-11-12 Thread Geir Hauge
2011/11/12 Chris F.A. Johnson > On Fri, 11 Nov 2011, Peng Yu wrote: > >> I'm wondering if I already have a string variable, is there a bash >> native to do tilde expansion on it. >> >> var='~/..' >> cd $var#how to change this line? >> > > eval "cd $var" > I'd avoid eval as that could potentiall

Re: invoke tilde expansion on quoted string

2011-11-11 Thread Chris F.A. Johnson
On Fri, 11 Nov 2011, Peng Yu wrote: I know from the document that tilde expansion only works if the string is unquoted (see below) ~$ cd '~/..' -bash: cd: ~/..: No such file or directory ~$ cd ~/.. /Users$ I'm wondering if I already have a string variable, is there a bash native to do tilde ex

invoke tilde expansion on quoted string

2011-11-11 Thread Peng Yu
Hi, I know from the document that tilde expansion only works if the string is unquoted (see below) ~$ cd '~/..' -bash: cd: ~/..: No such file or directory ~$ cd ~/.. /Users$ I'm wondering if I already have a string variable, is there a bash native to do tilde expansion on it. var='~/..' cd $var