Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

puzzle: passing space to bash

7 views
Skip to first unread message

jafo...@my-deja.com

unread,
Aug 4, 1999, 3:00:00 AM8/4/99
to
given that you can pass an almost arbitrary string to bash,
(no white space or slashes) and there are no nice utilities
like sed, ed, cut, perl, etc., but awk and tcl are in the
search path, the puzzle is how to construct a command string
that has a space in it (e.g. a command with parameters).
changing IFS almost works, except for the trivial detail of
needing to "export IFS" which has a space in it. I've played
a bit with trying to pass characters as octal values, but no
joy so far.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Ken Pizzini

unread,
Aug 4, 1999, 3:00:00 AM8/4/99
to
On Wed, 04 Aug 1999 00:39:45 GMT, <jafo...@my-deja.com> wrote:
>given that you can pass an almost arbitrary string to bash,
>(no white space or slashes) and there are no nice utilities
>like sed, ed, cut, perl, etc., but awk and tcl are in the
>search path, the puzzle is how to construct a command string
>that has a space in it (e.g. a command with parameters).
>changing IFS almost works, except for the trivial detail of
>needing to "export IFS" which has a space in it. I've played
>a bit with trying to pass characters as octal values, but no
>joy so far.

I don't think I'm understanding the question properly, because
the answer of "don't muck with IFS, just quote the space" seems
to be too trivial:
"this tries to invoke an executable with spaces in its name" \
"and this is an argument which contains spaces"

--Ken Pizzini

jafo...@my-deja.com

unread,
Aug 4, 1999, 3:00:00 AM8/4/99
to
Ken,

you are correct in that you did not completely understand the question.
The problem is that there can *not* be any explicit whitespace
characters in the string. So "this is a string with spaces" won't
work. something like "cd`something`somedir" where `something` returns
a space (or tab) but not a newline, is what I am looking for.

jafo

In article <slrn7qfgk...@pulsar.halcyon.com>,

Ken Pizzini

unread,
Aug 4, 1999, 3:00:00 AM8/4/99
to
On Wed, 04 Aug 1999 13:03:48 GMT, <jafo...@my-deja.com> wrote:
>> >given that you can pass an almost arbitrary string to bash,
>> >(no white space or slashes) and there are no nice utilities
>> >like sed, ed, cut, perl, etc., but awk and tcl are in the
>> >search path, the puzzle is how to construct a command string
>> >that has a space in it (e.g. a command with parameters).
>> >changing IFS almost works, except for the trivial detail of
>> >needing to "export IFS" which has a space in it. I've played
>> >a bit with trying to pass characters as octal values, but no
>> >joy so far.

>The problem is that there can *not* be any explicit whitespace


>characters in the string. So "this is a string with spaces" won't
>work. something like "cd`something`somedir" where `something` returns
>a space (or tab) but not a newline, is what I am looking for.

So you mean something like:
bash -c 'IFS=,;cmd=ls,-l;$cmd'
?

If that's a valid answer then I'll point out that you were
extremely close, you just failed to note that there is no need
to export the IFS.

--Ken Pizzini

Casper H.S. Dik - Network Security Engineer

unread,
Aug 7, 1999, 3:00:00 AM8/7/99
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

jafo...@my-deja.com writes:

>given that you can pass an almost arbitrary string to bash,
>(no white space or slashes) and there are no nice utilities
>like sed, ed, cut, perl, etc., but awk and tcl are in the
>search path, the puzzle is how to construct a command string
>that has a space in it (e.g. a command with parameters).
>changing IFS almost works, except for the trivial detail of
>needing to "export IFS" which has a space in it. I've played
>a bit with trying to pass characters as octal values, but no
>joy so far.

Hm, why not:

echo${IFS}foo

No spaces, but executes "echo foo".

What do I win?

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

James Avery

unread,
Aug 14, 1999, 3:00:00 AM8/14/99
to

On Wed, 4 Aug 1999 jafo...@my-deja.com wrote:

> Ken,
>
> you are correct in that you did not completely understand the question.

> The problem is that there can *not* be any explicit whitespace

> characters in the string. So "this is a st ring with spaces" won't


> work. something like "cd`something`somedir" where `something` returns
> a space (or tab) but not a newline, is what I am looking for.
>

> jafo

What about this\ is\ a\ string\ with\ spaces? I'm positive that you won't
have to do something as ugly as what you're proposing. :)

--
Med venlig hilsen,
James Avery <av...@io.dk>

0 new messages