0

I'm following The Unix Programming Environment exercises and have encountered some weird issues. While going through the ed exercise, when you just start ed, type in the exercise, then do

 w poem

It saves in the filesystem as 'poem ' I tested another file, start ed, type in some words,

w raistlin 

and it saves as 'raistlin ' with the same result (filename in single quotes followed by one space), though I tested on a third, and if I start off with the file name it saves as a normal file. Has anyone else seen these results? I know it's a little esoteric, I think I'm probably 1 of 7 people on the whole earth using ed this weekend. I'm using Manjaro Arch.

Kusalananda
  • 333,661
Mark Scheck
  • 250
  • 1
  • 10
  • 1
    I can't reproduce this with GNU ed nor with the native ed on OpenBSD. Where do you see these filenames, is it in the ls output? What does printf '>>%s<<\n' * output for these files? – Kusalananda Nov 28 '20 at 08:49
  • Yes it's in the ls output. It gets's weirder I switched window managers from dwm to xfce and it seems have gone away. I was using terminator on dwm and now xfce-terminal. So it's a terminal issue??? – Mark Scheck Nov 28 '20 at 09:04
  • 1
    Could well be a terminal issue, yes, or something else relating to your graphical desktop setup. I can't unfortunately test identical setups to yours... Does text that you input get modified in a similar way in any other terminal application? (I'm guessing it's not actually related to ed but to something that your input is passing through). – Kusalananda Nov 28 '20 at 09:07
  • I thought I saw something weird in vi a few weeks ago, but didn't write it down. I'll test on my Debian system as well going back into dwm and testing with a couple of different terminal apps. – Mark Scheck Nov 28 '20 at 09:13
  • Could you check whether the odd filenames contains Unicode characters? Possibly by printf '%s\n' PATTERN | od -ah where PATTERN is some pattern that matches at least of the names. – Kusalananda Nov 28 '20 at 09:24
  • I think I got it, was putting a trailing space at the end of the filename. @Kusalananda thanks for all the help. I'm not sure if I should be happy or sad for getting all ADD about this. – Mark Scheck Nov 28 '20 at 10:14
  • Good! If you want to submit an answer to this describing what the issue was and how you resolved it, that would be good. Otherwise we will likely close and/or delete this question. – Kusalananda Nov 28 '20 at 10:17

2 Answers2

2

According to the originating user, they accidentally added a space character at the end of the filename when saving the file in ed.

w test 

(extra space typed after the test string above)

Doing so will provoke GNU ls to add single quotes around the filename in its output. It would do this to any filename that is "unusual". In this case, because it contains a space character.

$ ls -l
total 4
-rw-rw-r-- 1 myself myself 6 Mar  9 21:17 'test '

You can get GNU ls to output unquoted filenames if you wish, using either ls --literal, ls -N, ls --quoting-style=literal, or by setting the environment variable QUOTING_STYLE to the string literal. However, since ls output is only meant for looking at, it doesn't really matter.

Related:

Kusalananda
  • 333,661
1

Seems that it was an extra space after the filename. So when you specify the filename like this.

ed poem

it works fine. Inside ed be extremely careful when you are typing the commands like this:

w poem(enter)

... and not:

w poem (enter)
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Mark Scheck
  • 250
  • 1
  • 10