Commit Graph

720 Commits

Author SHA1 Message Date
Linus Groh
8f2300afb5 mkdir: Add -p option to create parent directories 2020-04-28 09:36:09 +02:00
Linus Groh
6fd7966d81 mkdir: Use ArgParser, support creating multiple directories 2020-04-28 09:36:09 +02:00
Linus Groh
9540174b40 js: Follow Serenity C++ naming conventions 2020-04-26 18:09:22 +02:00
Luke Payne
f191b84b50 Kernel: Added the ability to set the hostname via new syscall
Userland/hostname: Now takes parameter to set the hostname
LibC/unistd: Added sethostname function
2020-04-26 12:59:09 +02:00
bcoles
03f68a51af
Userland: Add arp utility (#1962) 2020-04-26 12:54:22 +02:00
Brian Gianforcaro
597ff9ec93 Userland: Fix kill to support negative pid values.
The kill system call accepts negative pids, as they
have special meaning:

    pid == -1 means all processes the calling process has access to.

    pid < -1 means every process who's process group ID is -pid.

I don't see any reason why the user space program should mask this.
2020-04-26 12:54:10 +02:00
Andreas Kling
35aea2e454 LibJS: Stop using Optional<Value> in favor of Value's empty state
JS::Value already has the empty state ({} or Value() gives you one.)
Use this instead of wrapping Value in Optional in some places.
I've also added Value::value_or(Value) so you can easily provide a
fallback value when one is not present.
2020-04-25 18:45:22 +02:00
Hüseyin ASLITÜRK
e00b85b8c0 Userland/ls: Remove unnecessary output 2020-04-25 12:09:46 +02:00
Linus Groh
a832ab0f4e js: Interrupt running script or REPL evaluation when receiving SIGINT 2020-04-24 19:43:34 +02:00
Linus Groh
95b51e857d LibJS: Add TokenType::TemplateLiteral
This is required for template literals - we're not quite there yet, but at
least the parser can now tell us when this token is encountered -
currently this yields "Unexpected token Invalid". Not really helpful.

The character is a "backtick", but as we already have
TokenType::{StringLiteral,RegexLiteral} this seemed like a fitting name.

This also enables syntax highlighting for template literals in the js
REPL and LibGUI's JSSyntaxHighlighter.
2020-04-24 11:18:57 +02:00
Andreas Kling
52a250cb61 LibGUI: Make MenuBar a Core::Object
This makes it show up in Inspector with all the menus inside it. :^)
2020-04-21 16:19:18 +02:00
Andreas Kling
98b990f20b Userland: Remove some little temporary test programs
These were never meant to stick around.
2020-04-19 19:40:04 +02:00
Andreas Kling
7eeea4d57f Kernel: rmdir("/") should fail instead of asserting
We can't assume there's always a parent custody -- when we open "/"
there isn't gonna be one!

Fixes #1858.
2020-04-19 18:07:16 +02:00
Andreas Kling
4c19305a17 test_io: Unbreak symlink test after sys$readlink() '\0' changes 2020-04-19 18:07:09 +02:00
AnotherTest
cb3cf589ed LibLine: Allow suggestions to have trailing trivia strings
These strings would be applied when inserted into the buffer, but are
not shown as part of the suggestion.

This commit also patches up Userland/js and Shell to use this
functionality
2020-04-19 17:21:55 +02:00
Sergey Bugaev
b6eb7f42ac Userland: Add open(1)
This is a simple utility for invoking Core::DesktopServices::open() from command
line :^)
2020-04-19 11:14:26 +02:00
Andreas Kling
fca08bd000 LibJS: Move builtin prototypes to the global object
This moves us towards being able to run JavaScript in different global
objects without allocating a separate GC heap.
2020-04-18 13:24:45 +02:00
Andreas Kling
6833004a45 js: Tweak the live syntax highlighting colors a bit 2020-04-16 16:37:32 +02:00
Itamar
ef6dc61291 functrace: Log syscalls 2020-04-16 11:17:33 +02:00
Itamar
f4418361c4 Userland: Add "functrace" utility
functrace traces the function calls a program makes.
It's like strace, but for userspace.

It works by using Debugging functionality to insert breakpoints
at call&ret instructions.
2020-04-16 11:17:33 +02:00
Andreas Kling
64f5185bae js: Tweak colorization of printed values a bit 2020-04-15 10:11:48 +02:00
Sergey Bugaev
f18d6610d3 Kernel: Don't include null terminator in sys$readlink() result
POSIX says, "Conforming applications should not assume that the returned
contents of the symbolic link are null-terminated."

If we do include the null terminator into the returning string, Python
believes it to actually be a part of the returned name, and gets unhappy
about that later. This suggests other systems Python runs in don't include
it, so let's do that too.

Also, make our userspace support non-null-terminated realpath().
2020-04-14 18:40:24 +02:00
Brian Gianforcaro
d74ad81402 js/LibJS: Move test functions to pure javascript.
The addition of assert functions to Userland/js
was done before we had load(..) implemented. Now
that it exists, it seems like the right move the
test helper functions to pure javascript instead
of poluting js with random global functions.
2020-04-14 12:55:31 +02:00
Linus Groh
8e08d111da js: Output text using printf() and return undefined in help() 2020-04-13 23:12:17 +02:00
Linus Groh
0040d6bf2d js: Add assertNotReached() function in test mode 2020-04-13 16:28:50 +02:00
Stephan Unverwerth
984c290ec0 LibJS: Do not execute scripts with parse errors
This adds missing checks in several LibJS consumers.
2020-04-13 10:42:25 +02:00
Brian Gianforcaro
50b6b6ef86 js: Make load() available when running with --test-mode
The work I did to add assert as a native function in js
was a step in the wrong direction. Now that js supports
load() it makes sense to just move assert and anything
we want to add to the test harness into pure javascript.
2020-04-13 10:31:06 +02:00
Itamar
8e87d340c3 strace: Update ptrace() usage
ptrace with PT_TRACEME was updated to also stop the traced thread on
exit from execve.
2020-04-13 00:53:22 +02:00
Linus Groh
6d5d668585 js: Coerce assert() argument to boolean
It's JavaScript after all :^)
2020-04-13 00:47:53 +02:00
Linus Groh
31d0dbe2a0 js: Stylize TokenType::{Throw,Switch,Case} 2020-04-11 17:15:40 +02:00
AnotherTest
2fdce695d6 LibLine: Display suggestions and cycle between them
With extra color (tm)
This commit also patches the users of LibLine to properly use the new
API
2020-04-11 17:15:19 +02:00
AnotherTest
70da0e3fb5 Userland: Add primitive autocomplete to the JS repl
This patch adds primitive support for autocompletion in the JS repl,
it only supports completing global names and properties on variables :^)
2020-04-11 14:29:25 +02:00
AnotherTest
586aa3b1de Userland: Install LibLine's signal handlers in the JS repl 2020-04-11 14:29:25 +02:00
Andreas Kling
e5cde0082a LibX86: Run the instruction decoder in 32-bit mode by default
Let's assume a 32-bit execution environment unless otherwise specified.
2020-04-11 13:24:55 +02:00
Andreas Kling
32d83fdee4 LibX86: Add an X86 instruction decoder library + basic disassembler
This will be very useful for developer tools like ProfileView, and also
for future tools like debuggers and such. :^)
2020-04-11 13:16:17 +02:00
AnotherTest
6545a74743 JS repl: Fix indentation when a line starts with '})]' 2020-04-10 00:58:59 +02:00
Linus Groh
c06a6c67d5 LibJS: Add globalThis
We already have "global" as a way to access the global object in js(1)
(both REPL and script mode). This replaces it with "globalThis", which
is available in all environments, not just js.
2020-04-09 15:58:49 +02:00
Linus Groh
755b206618 LibJS: Handle empty values in Value::to_string() 2020-04-08 18:51:34 +02:00
Andreas Kling
bdffc9e7fb LibJS: Support array holes, encoded as empty JS::Value
This patch adds a new kind of JS::Value, the empty value.
It's what you get when you do JSValue() (or most commonly, {} in C++.)

An empty Value signifies the absence of a value, and should never be
visible to JavaScript itself. As of right now, it's used for array
holes and as a return value when an exception has been thrown and we
just want to unwind.

This patch is a bit of a mess as I had to fix a whole bunch of code
that was relying on JSValue() being undefined, etc.
2020-04-06 20:27:44 +02:00
Andreas Kling
90ba0145f6 LibJS: Add a number-indexed property storage to all Objects
Objects can have both named and indexed properties. Previously we kept
all property names as strings. This patch separates named and indexed
properties and splits them between Object::m_storage and m_elements.

This allows us to do much faster array-style access using numeric
indices. It also makes the Array class much less special, since all
Objects now have number-indexed storage. :^)
2020-04-06 18:09:26 +02:00
Liav A
23fb985f02 Kernel & Userland: Allow to mount image files formatted with Ext2FS 2020-04-06 15:36:36 +02:00
Andreas Kling
e323246517 Meta: Add missing copyright headers 2020-04-06 11:09:01 +02:00
AnotherTest
d077637fd6 JS Repl: Add live syntax highlighting
This patchset adds live syntax highlighting to the js repl.
It is turned off by default and can be enabled via the -s flag.
2020-04-05 16:11:13 +02:00
Brian Gianforcaro
4233c8662b js: Add a new --test-mode option, which exposes an assert() function.
Introduce a central assert implementation so that the LibJS test suite
can take advantage of one implementation instead of copy/pasting the
same function into every test case file.
2020-04-05 15:28:45 +02:00
AnotherTest
77191d82dc Kernel: Add the SO_BINDTODEVICE socket option
This patch adds a way for a socket to ask to be routed through a
specific interface.
Currently, this option only applies to sending, however, it should also
apply to receiving...somehow :^)
2020-04-05 09:50:48 +02:00
Linus Groh
79539378c6 js: Add lines to history 2020-04-05 01:54:38 +02:00
Andreas Kling
2db8716a6f LibJS: Don't return the "last computed value" from Interpreter::run()
Only return whatever a "return" statment told us to return.
The last computed value is now available in Interpreter::last_value()
instead, where the REPL can pick it up.
2020-04-04 23:45:13 +02:00
Andreas Kling
fc5067afd2 ProtocolServer+LibProtocol: Reject unhandled URLs instead of asserting
StartDownload requests for unhandled protocols (or invalid URLs) will
now refuse to load instead of asserting. A failure code is sent back
to LibProtocol and Protocol::Client::start_download() returns nullptr.

Fixes #1604.
2020-04-04 20:01:36 +02:00
Andreas Kling
040ba77d44 Userland: Fix null-pointer deref on unknown user/group in chown/chgrp
We can't just blindly dereference the result of getpwnam()/getgrnam()!

Fixes #1625.
2020-04-04 19:29:30 +02:00
Linus Groh
cd3e2690eb LibJS: Set length property in Object::put_native_function() 2020-04-04 15:58:49 +02:00