LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash -D (or bash --dump-strings) unexpected result (http://www.linuxquestions.org/questions/linux-general-1/bash-d-or-bash-dump-strings-unexpected-result-864691/)

Ubx 02-24-2011 01:25 AM

bash -D (or bash --dump-strings) unexpected result
 
Instead of a dump of $ strings, I'm getting a prompt that doesn't process commands and seemingly can't be exited. Is this correct? I don't have access to a BSD or other Unix environment to allow a comparison with a non-GNU environment, but the current result certainly doesn't match the man page.

I've tried this with the following environments:
  • Ubuntu 9.10 (GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu))
  • Centos 5.5 (GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu))

Dark_Helmet 02-24-2011 06:27 PM

Can't say I know exactly what that command switch is for, but...

I ran it on a virtual machine (e.g. "bash -D"), and yes, you get another Bash environment--in other words a shell within a shell, but without any environment variables. For instance, my subshell had a prompt of "bash-4.1$" which (I believe) is the default prompt if $PS1 is not set.

Also, you can exit the sub-shell by pressing Ctrl-D.

Again, I'm not sure what the -D is supposed to accomplish. I just glanced at the man page, but as I recall, the description did say "no commands will be executed."

I'll play with it a little more and see if I can figure out exactly what it's intended use is.

EDIT:
Well, playing with it some and reading the man page literally:
Code:

DH@virtUbuntu:~$ bash -D
bash-4.1$ "hello"
bash-4.1$ "PS1"
bash-4.1$ $"PS1"
"PS1"
bash-4.1$ $PS1
bash-4.1$ "$PS1"
bash-4.1$ $"$PS1"
"$PS1"
bash-4.1$ <Ctrl-D>
DH@virtUbuntu:~$

So, as the man page says:
Quote:

A list of all double-quoted strings preceded by $ is printed on the standard output
I imagine you would redirect standard input from a file, the output of a command, or something else to make this more useful.

EDIT2:

As an example:
Code:

DH@virtUbuntu:~$ echo '$"greetings" "earthling" "we" $"are" "your" $"new" $"overlords"' > test_data.txt
DH@virtUbuntu:~$ bash -D < test_data.txt
"greetings"
"are"
"new"
"overlords"
DH@virtUbuntu:~$


onebuck 02-24-2011 07:41 PM

Hi,

Welcome to LQ!
Quote:

Originally Posted by Ubx (Post 4269308)
Instead of a dump of $ strings, I'm getting a prompt that doesn't process commands and seemingly can't be exited. Is this correct? I don't have access to a BSD or other Unix environment to allow a comparison with a non-GNU environment, but the current result certainly doesn't match the man page.

I've tried this with the following environments:
  • Ubuntu 9.10 (GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu))
  • Centos 5.5 (GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu))

I would start at 4,5 &6 below since your query requirements are aligned to these. Look at Rute for some useful examples. While the other links will enhance your Gnu/Linux experience;



1 Linux Documentation Project
2 Rute Tutorial & Exposition
3 Linux Command Guide
4 Bash Beginners Guide
5 Bash Reference Manual
6 Advanced Bash-Scripting Guide
7 Linux Newbie Admin Guide
8 LinuxSelfHelp
9 Utimate Linux Newbie Guide

The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!


All times are GMT -5. The time now is 07:14 PM.