Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExpansionのToDo #42

Open
8 tasks done
moromin opened this issue Oct 3, 2021 · 11 comments
Open
8 tasks done

ExpansionのToDo #42

moromin opened this issue Oct 3, 2021 · 11 comments
Assignees
Labels
todo Not a bug, but need to be changed

Comments

@moromin
Copy link
Collaborator

moromin commented Oct 3, 2021

概要

  • 環境変数の展開
  • &&, ||などがある場合の展開の順番
  • wildcard
    • ASCIIコード順に文字列ソート
  • word splitting
    • ',"の中はsplitしない
  • removal quotes
  • ', "の中にいるかどうかの状態管理

参考リンク(あれば)

以下のリンクからテンプレートを拝借

@moromin moromin self-assigned this Oct 3, 2021
@moromin
Copy link
Collaborator Author

moromin commented Oct 4, 2021

wildcardの表示する順番どうしよう?
readdir()で取得した文字列をそのままの順番で表示すると、bashの挙動とズレる;;

readdir()のmanにも書いてないし、取得する順番は処理系依存らしい
どうにもできねぇ感がすごい笑

@takumihara
Copy link
Owner

bashはどういう順番で表示するんですか?

@moromin
Copy link
Collaborator Author

moromin commented Oct 4, 2021

current directoryがこんな感じの時、

.
├── AA 
│   └── aa
├── AB
│   └── ab
├── AC <- file
├── Makefile
├── a.out
├── expansioner_test.c
├── expansioner_wildcard_test.c
└── obj
    ├── assign_mem.o
    ├── ast.o
     ....

lsした時と同じ順番になるっぽいんですが、lsの順番もASCIIコード順とかディレクトリ、タイムスタンプ順なのかな?と思ったら、表示順がごちゃごちゃになってて訳わかりませんwww

$ ls -l
total 256
drwxr-xr-x@  3 kazuma  staff      96 Oct  4 12:49 AA
drwxr-xr-x@  3 kazuma  staff      96 Oct  4 12:49 AB
-rw-r--r--   1 kazuma  staff       1 Oct  4 12:48 AC
-rw-r--r--   1 kazuma  staff    1372 Oct  4 11:20 Makefile
-rwxr-xr-x   1 kazuma  staff  111440 Oct  4 12:22 a.out
-rw-r--r--   1 kazuma  staff    6542 Oct  4 12:11 expansioner_test.c
-rw-r--r--   1 kazuma  staff       0 Oct  4 12:49 expansioner_wildcard_test.c
drwxr-xr-x@ 26 kazuma  staff     832 Oct  4 12:22 obj

$ echo *
AA AB AC Makefile a.out expansioner_test.c expansioner_wildcard_test.c obj

@moromin
Copy link
Collaborator Author

moromin commented Oct 4, 2021

.*みたいな隠しファイルも表示しないっすね
readdir()は取得しちゃいますけどww

@moromin
Copy link
Collaborator Author

moromin commented Oct 4, 2021

GuacamoleのlocaleCだったので、ローカル環境のlocaleも変更して、ソートが必要そうなら実装する感じでいきます!

c1r3s8% locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

@takumihara
Copy link
Owner

なるほどです、あんまり理解できてないですけど、PR楽しみにしておきます!!笑

@moromin
Copy link
Collaborator Author

moromin commented Oct 4, 2021

今試したらlocale=Cにしても表示順に影響ないっぽいす....
一旦保留!笑

@moromin moromin linked a pull request Oct 4, 2021 that will close this issue
@moromin moromin removed a link to a pull request Oct 5, 2021
@moromin moromin reopened this Oct 5, 2021
@moromin moromin added the todo Not a bug, but need to be changed label Oct 6, 2021
@moromin
Copy link
Collaborator Author

moromin commented Oct 30, 2021

以下のように、ワイルドカードが複数マッチする場合

$ echo *.*

$ echo *a*file

@moromin
Copy link
Collaborator Author

moromin commented Oct 31, 2021

$ ls
... res* ...
$ echo *"*"
res*

@moromin
Copy link
Collaborator Author

moromin commented Oct 31, 2021

pre, mid, post の3段階に分けて実装できそう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
todo Not a bug, but need to be changed
Projects
None yet
Development

No branches or pull requests

2 participants