-
Notifications
You must be signed in to change notification settings - Fork 1
ДЗ №4 "Cd Ls" #3
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
base: grep
Are you sure you want to change the base?
Conversation
|
Я не совсем понял, а что вы от них хотите?
|
| File(path).canonicalFile | ||
| } else { | ||
| File(workingDirectory, path).canonicalFile | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эта логика уже реализована в Path.resolve
| } | ||
|
|
||
| private fun isAbsolutePath(path: String): Boolean { | ||
| return File.listRoots().fold(false) { res, file -> res || path.startsWith(file.canonicalPath) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И это тоже не нужно, если работать с путями через Path
| */ | ||
| override fun execute(output: PipedWriter) { | ||
| if (arguments.size > 1) { | ||
| output.write("cd: too many arguments") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не надо смешивать поток вывода команд и сообщения об ошибках. Бросайте исключения
| output.write("cd: too many arguments") | ||
| return | ||
| } | ||
| if (!env.changeDirectory(arguments.getOrElse(0) { "./" })) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не кроссплатформенно.
>pwd
C:\practice\kuporosov\SoftwareDesign\bash
>cd
>pwd
C:\practice\kuporosov\SoftwareDesign\bashThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А, тогда кроссплатформенно не работает)
cd без аргументов должна менять рабочую директорию на домашнюю
Ожидалось такое поведение:
>pwd
C:\practice\kuporosov\SoftwareDesign\bash
>cd
>pwd
C:\Users\АртёмThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
То есть надо обеспечить разное поведение на разных системах?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет, одинаковое - переход в домашнюю папку
Насколько я понял из данного обсуждения, стандарт java не предусматривает обязательной поддержки механизма, позволяющего поменять рабочую директорию. |
| */ | ||
| override fun execute(output: PipedWriter) { | ||
| if (arguments.size > 1) { | ||
| output.write("ls: too many arguments") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В ls ещё не исправили вывод сообщений об ошибках
|
Можно было бы отдельный класс ошибки создать, а не использовать RuntimeException. |
yurii-litvinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Последовательность команд
cd ..
ls
.git
.gitignore
bash
LICENSE
cat LICENSE
не приводит к ожидаемому результату, будто cat не знает про смену папки.
Но это единственный замеченный недостаток, так что не буду просить исправить, зачтена.


В целом архитектура порадовала.
Из плюсов:
Из минусов: