oh-my-fish / theme-dangerous

A feature-rich theme derived from budspencer without powerline font.
33 stars 8 forks source link

function c error: read: Argument '-l' must be an integer #3

Open dbellavista opened 8 years ago

dbellavista commented 8 years ago

When I try to use the c command, I get this error:

❯ 3 ❯❯ ✔ ❯ c                                                                                                                                                                                                                             ❮ ~ ❮
› 1   cd /tmp/
› 0   cd ~
expr: syntax error
read: Argument '-l' must be an integer
~/.config/fish/functions/fish_prompt.fish (line 253):   read -p 'echo -n (set_color $dangerous_colors[9])"↩ Exec [e|0"$last_item"] ❯ "' -n $input_length -l cmd_num
                                                        ^
in function 'c'
    called on standard input

       read ‐‐ read line of input into variables

   Synopsis
       read [OPTIONS] [VARIABLES...]

read: Type 'help read' for related documentation

switch: Expected exactly one argument, got 0

~/.config/fish/functions/fish_prompt.fish (line 25):   switch $cmd_num
                                                              ^
in function 'c'
    called on standard input
tannhuber commented 8 years ago

Hi @dbellavista,

you use Mac OS X, don't you? See here.

dbellavista commented 8 years ago

Oh right, it's the freebsd version of the program, isn't it? Thanks

On Fri, Dec 25, 2015, 6:09 PM tannhuber notifications@github.com wrote:

Hi @dbellavista https://github.com/dbellavista,

you use Mac OS X, don't you? See here https://github.com/oh-my-fish/theme-budspencer#note-for-os-x-users.

— Reply to this email directly or view it on GitHub https://github.com/oh-my-fish/theme-dangerous/issues/3#issuecomment-167251860 .

stek29 commented 8 years ago

@tannhuber Maybe it's better to use gsed and gexpr, or modify path?

bobthecow commented 8 years ago

@dbellavista what does type read tell you?

bobthecow commented 8 years ago

(in this case, it doesn't look like it's a sed/expr issue. it looks like it's an issue with read not using the builtin)

stek29 commented 8 years ago

@bobthecow I have same issue, and read is a builtin

tannhuber commented 8 years ago

Sorry for the delay. The problem is your expr command. It's explained in the README. Have you checked that you use the coreutils version?

ericwooley commented 8 years ago

@tannhuber How do you check that?

tannhuber commented 8 years ago

expr --version

predmijat commented 8 years ago

I had this error on OS X (for theme budspencer) and fixed by installing gnu coreutils and adding them to path - https://github.com/oh-my-fish/theme-budspencer/issues/6

Now I've started getting switch: Expected exactly one argument, got 0 on Arch Linux.

Output of expr --version is the same on both OS X and Arch, only Arch produces errors:

expr --version
expr (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Parker, James Youngman, and Paul Eggert.

Not sure what is wrong...

tannhuber commented 8 years ago

@predmijat That's really strange. I've Arch with expr from coreutils 8.25 as well. It would be nice if you could help me. Can you insert

echo "***" $input_length

before the read command in line 253 within fish_prompt.fish and tell me the output when you type c?

Thanks in advance!

predmijat commented 8 years ago

After adding that line c produces "Command history is empty. It will be created automatically."

Additional details: I get errors only the first time (right after I install a theme, dangerous or budspencer doesn't matter). After that, when I SSH to that server, prompt colors suggest that I'm in Vi's command mode (as if I pressed ESC, which I didn't).

I can type any command and after that first command fish stops working. I can no longer type anything, I have to kill that session, reconnect, use that one available command I have to su to another user (root), delete all traces of the theme, and only then I can continue to use fish as my default user.

Let me know if I can provide you with more information...I have no idea where to look.

tannhuber commented 8 years ago

I forgot to tell you that you must type at least one command in advance to fill the command history. The c command should print a line containing three asterisks plus a number. The number would be important for me to check whether expr works as expected.

The second problem seems to me that you haven't enabled fish_vi_key_bindings within your ssh session. You should be able to check your settings with echo $fish_key_bindings. The first command works, am I right?

predmijat commented 8 years ago

Yeah...that was it...sorry for the false alarm, I thought it was related to this issue...

stek29 commented 8 years ago

Now one more problem: history still doesn't work on OS X because of xsel usage

tannhuber commented 8 years ago

xsel is not that important. You can try to deactivate it with a simple function definition:

function xsel
end

Same for wmctrl.