Why can't I name a "story" from Ruby?

I can run Bash shell commands using a Ruby or irb program using backlinks (and% x (), system, etc.). But for some reason this does not work with history.

For instance:

jones$ irb --simple-prompt
>> `whoami`
=> "jones\n"
>> `history`
(irb):2: command not found: history
=> ""

Inside the Ruby program, it raises this error:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31: command not found: history

In bash, these commands work fine

It's not that calling Ruby calls a new shell - it just doesn't find this command ...

Does anyone know why? I'm at a dead end ...

+3
source share
3 answers

unix , backtick script. , bash, ; , bash. history - . - bash, .

type, , , ruby ​​( python, perl, Tcl .. script). :

$ type history
history is a shell builtin
$ type cat
cat is /bin/cat

, , .bashrc, .

, exec' " ", " ". , .

+10

. , , :

`bash -c 'history'`

, , .

+3
{~} ∴ which history
history: shell built-in command
0
source

Source: https://habr.com/ru/post/1765659/


All Articles