command line - How can I solve "unmatched double quote" error using dbus-monitor in combination with xargs? - Ask Ubuntu


to intercept (notify-osd) notifications on linux (ubuntu), using dbus-monitor script below. subsequently, script runs script (/opt/nonotifs/nonotifs/silent) intercepted notification argument, further processing:

#!/bin/bash  dbus-monitor "interface='org.freedesktop.notifications'" | \ grep --line-buffered "string" | \ grep --line-buffered -e method -e ":" -e '""' -e urgency -e notify -v | \ grep --line-buffered '.*(?=string)|(?<=string).*' -opi | \ grep --line-buffered -v '^\s*$' | \ xargs -i '{}' /opt/nonotifs/nonotifs/silent {} 

this works flawlessly, except notifications hplip.

enter image description here

when run terminal, script above shows:

xargs: unmatched double quote; default quotes special xargs unless use -0 option 

when using option -0 however, script delivers no argument @ all.

what tried

in cases, script subsequently breaks. if always case, worked around running in "keep alive" -wrapper, tried. however, script not terminate, stops returning intercepted notifications nevertheless.

how can solve this?

edit

as suggested @serg, replaced xargs... section cat -a, see passed xargs. shows indeed there unmatched double quote in notification of hplip (the third line), seems bug in notification.

the output when running cat -a, calling notification:

"hplip"$  "hplip device status"$  "officejet_pro_8600$  "transient"$ 

from man xargs:

--delimiter=delim -d delim       input  items  terminated specified character.  quotes       , backslash not special; every character in  input        taken  literally.   disables   end-of-file  string,       treated other argument.   can   used  when        input consists of newline-separated items, although       better design program use --null          possible.    specified  delimiter  may single       character, c-style character escape such \n, or octal or       hexadecimal escape code.  octal , hexadecimal escape codes       understood printf command.   multibyte characters       not supported. 

as example:

$ echo '"""' | xargs \xargs: unmatched double quote; default quotes special xargs unless use -0 option $ echo '"""' | xargs -d '\n' """  $ echo '"""' | xargs -d ' '  """ 

of course, using either may break things, perhaps not as -0.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User