radareorg / sdb

Simple and fast string based key-value database with support for arrays and json
https://www.radare.org/
MIT License
217 stars 62 forks source link

double newline after each query - intentionally? (/src/query.c line 21?) #208

Closed is-this-a-comma-or-period closed 2 years ago

is-this-a-comma-or-period commented 4 years ago

Describe the issue Every query result is appended 2 newline characters (identified as 0x0a).

This happens in any query mode that I checked. This makes parsing results ... weird. Is this intentionally?

How to reproduce?

$ sdb - a=alpha b=bravo a b
alpha

bravo

$ sdb - a=alpha b=bravo a b | hexdump -C
00000000  61 6c 70 68 61 0a 0a 62  72 61 76 6f 0a 0a        |alpha..bravo..|
0000000e

Expected behavior

1 newline after each query.

Possible fix

Please note that double newline somewhere in the documentation, if it is there on purpose. (maybe it is documented but I overlooked or misunderstood it.)

I poked in the code and removed line 21 of /src/query.c and I got only 1 newline character.

https://github.com/radareorg/sdb/blob/eb148d80186b232f380043b43463a79704a4c0a3/src/query.c#L21

As this #define is set I guess there is most likely some idea behind it.

Additional context

Downloaded ZIP file from github, extracted, cd, make, sudo make install

running Linux Mint 19.2.

actually more a newb to C . My target use of sdb is in shell scripts (fish shell has no native support for key=value)

radare commented 4 years ago

Send a pr. But this behaviour is a design decission but im happy to change that behaviour

On 17 May 2020, at 18:54, is-this-a-comma-or-period notifications@github.com wrote:

 Describe the issue Every query result is appended 2 newline characters (identified as 0x0a).

This happens in any query mode that I checked. This makes parsing results ... weird. Is this intentionally?

How to reproduce?

$ sdb - a=alpha b=bravo a b alpha

bravo

$ sdb - a=alpha b=bravo a b | hexdump -C 00000000 61 6c 70 68 61 0a 0a 62 72 61 76 6f 0a 0a |alpha..bravo..| 0000000e Expected behavior

1 newline after each query.

Possible fix

Please note that double newline somewhere in the documentation, if it is there on purpose. (maybe it is documented but I overlooked or misunderstood it.)

I poked in the code and removed line 21 of /src/query.c and I got only 1 newline character.

https://github.com/radareorg/sdb/blob/eb148d80186b232f380043b43463a79704a4c0a3/src/query.c#L21

As this #define is set I guess there is most likely some idea behind it.

Additional context

Downloaded ZIP file from github, extracted, cd, make, sudo make install

running Linux Mint 19.2.

actually more a newb to C . My target use of sdb is in shell scripts (fish shell has no native support for key=value)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

trufae commented 2 years ago

Also fixed